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 animation with div elements created via Javascript. #56

Open
CaudellDev opened this issue Nov 6, 2014 · 5 comments
Open

No animation with div elements created via Javascript. #56

CaudellDev opened this issue Nov 6, 2014 · 5 comments

Comments

@CaudellDev
Copy link

When I create a div element with HTML and use move functions on it, it works just fine. However, when I use Javascript to create and element ( = document.createElement('div')), and set the class and Id, it won't animate with the move functions. It just jumps to the end position, even if I have the duration set.

@CaudellDev
Copy link
Author

Anyone else have this problem? I don't want to rely on only pre-defined divs, it would be much easier if I could make divs on the fly and animate them as well.

@mdgriffith
Copy link

I think I'm having the same issue. A hack I found that worked(though is obviously not what I want to keep around in my code) was to wrap the animation in a setTimeout with a wait of 1ms.

var anim = function() {
    move(elem)
             .set('left','120px')
             .duration(700)
             .end();
}
setTimeout(anim, 1);

@garethfoote
Copy link

I'm also experiencing this same issue and the workaround suggested by @mdgriffith is also working, although not ideal.

@ben-eb
Copy link

ben-eb commented Dec 2, 2014

+1

@mdgriffith
Copy link

It looks like the important part is forcing the layout, or waiting until its done automatically

After creating the element, requesting a property from it that requires a layout, like elem.clientHeight, should do the trick, though still a bit hackish.

http://stackoverflow.com/questions/12088819/css-transitions-on-new-elements

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

No branches or pull requests

4 participants