MithrilJS / mithril.js

A JavaScript Framework for Building Brilliant Applications
https://mithril.js.org
MIT License
13.99k stars 926 forks source link

CSS3 Animation with Mithril #1647

Closed volnei closed 7 years ago

volnei commented 7 years ago

Hi guys!

I'm loving to work with Mithril 1.0 (aka rewrite), it is fast and awesome! But I'm a bit confused with using CSS3 animation with it. Can anyone show a pratical example?

Thanks!

pygy commented 7 years ago

http://mithril.js.org/animation.html covers the basics. Is there something specific you want to discuss?

volnei commented 7 years ago

@pygy sorry for inconvenience... I just fall to look at the docs, cause I did not know they had already released the 1.0 documentation.

Thanks

pygy commented 7 years ago

No problem :-) have fun with the framework!

volnei commented 7 years ago

There any way to start animation by changing the class instead of adding or removing it?

Thanks :)

pygy commented 7 years ago

In onbeforeremove, you manipulate the real DOM directly... classList (IE 10+) allows to add and remove classes. For earlier browsers you have to manipulate the class string yourself.

For animations of an element that is just updated, in the view you can do

m('div', {className: condition ? 'foo' : 'bar'})

or use classnames for more advanced class manipulations.

dead-claudia commented 7 years ago

Closing, since this issue has not been updated in over a month. If you feel something in Mithril needs added or changed, please file a new issue.