Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No animations when compiling with Angular CLI #1658

Closed
DanielToft opened this issue Oct 8, 2019 · 6 comments · Fixed by #1834
Closed

No animations when compiling with Angular CLI #1658

DanielToft opened this issue Oct 8, 2019 · 6 comments · Fixed by #1834

Comments

@DanielToft
Copy link

Hi

When compiling SortableJS in production mode with angular CLI, there is no animations. I think, the build-optimizer maybe is removing some code.

I have found an old issue about the same here: SortableJS/ngx-sortablejs#70

I'm using the sortablejs library directly in my angular solution without ngx-sortablejs.

My environment look like this:
Angular: 8.2.9
Angular CLI: 8.3.8
sortablejs: 1.10.1

@owen-m1
Copy link
Member

owen-m1 commented Oct 9, 2019

There is currently a repaint function in the animation file that may be being removed in your build. Can you check whether or not it is in your compiled code?

@DanielToft
Copy link
Author

Hi @owen-m1

I can see that the repaint function is excluded and the call to repaint in the animate function is excluded too.

Here is the compiled animate function

animate: function(l, n, e, t) {
    if (t) {
        Ei(l, "transition", ""),
        Ei(l, "transform", "");
        var i = Di(this.el)
            , o = (n.left - e.left) / (i && i.a || 1)
            , u = (n.top - e.top) / (i && i.d || 1);
        l.animatingX = !!o,
        l.animatingY = !!u,
        Ei(l, "transform", "translate3d(" + o + "px," + u + "px,0)"),

        // repaint function should be here

        Ei(l, "transition", "transform " + t + "ms" + (this.options.easing ? " " + this.options.easing : "")),
        Ei(l, "transform", "translate3d(0,0,0)"),
        "number" == typeof l.animated && clearTimeout(l.animated),
        l.animated = setTimeout(function() {
            Ei(l, "transition", ""),
            Ei(l, "transform", ""),
            l.animated = !1,
            l.animatingX = !1,
            l.animatingY = !1
        }, t)
    }
}

@DanielToft
Copy link
Author

I think angulars build optimizer will remove unused properties, because it assumes that it has no side effects.

I assume that you are calling offsetWidth because you want to force a layout reflow?
Maybe you can use getClientRects() instead? It should force a reflow too, but i don't know if that method is slower.

@owen-m1
Copy link
Member

owen-m1 commented Oct 10, 2019

@DanielToft Does calling that function instead cause the code to stay in the compiled build?
Also yes I think it would be slower.

@denisr-w
Copy link

denisr-w commented Apr 6, 2020

Still having issues with that.
Animation not working, when --prod flag enabled.

@amay077
Copy link

amay077 commented Jul 31, 2020

Could you publish to NPM include this PR?

Runi-c pushed a commit to Tupperbox/Sortable that referenced this issue Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants