Version 2 🎉
In this release comes a complete TypeScript rewrite, more efficient engine, simplified codebase & documentation and a few new features.
-
Codebase: The codebase has been re-written in TypeScript and all main functions have been turned into classes.
-
MotionProps: The following keys have been removed:
ele
- This value is can be stored outside of theMotion
classstop
- This value is now controlled entirely by theMotion
classplayCount
- Is now built into theMotion
classreverseAfter
- This has been dropped in favour of manually toggling thereverse
key of the animation instance using.then()
, or using theLoopType.ALTERNATE
feature of theloop
key
-
Motion: The following features have been removed from the
Motion
class (formally function):.delay
- Animations don't play immediately when they are initiated any more and can now be started using the.play()
method.stop
- This value was poorly implemented to begin with, and has now been turned into a method which will reset an animation to its original state.eleBase
,.eleBaseUpdate
,.resetRect()
- These 3 were used when the animation needed to deal with the.getBoundingClientRect()
API, however if needed they can just be stored outside theMotion
object.toggleReverse()
- This can be done by just toggling the.reverse
value.reset()
- See new.stop()
method
-
MotionChain: The following features have been removed from the
MotionChain
class:.playReverse()
- This is now an optional boolean that can be passed into the.play()
method
MotionProps:
state
[Optional] - Added state object variable for custom persistent data- Example, initialize an animation once, but then dynamically change the element that it plays on
loop
[Optional] - Loop has changed from taking aboolean
to now taking aLoopType
enum which has 3 options:NONE
- DefaultLOOP
- Loops the animationALTERNATE
- Loops and transitions to the opposite position after each run instead of always starting at the beginning.
Motion:
- static
.preform(props: MotionProps)
- A factory builder function for instant initialisation and playback .stop()
- Will stop the animation and return it to its original state.pause()
- Can be called to pause an animation in its current position. Calling.play()
again would then resume the animation from its current state.rewind()
- Will rewind the animation from its current position back to the beginning.reset()
- By default, will call the first frame of the animation. However it can be set as a lambda on initialisation- Getters for some instance values:
.id
- The instance ID.isPaused
- If the instance is paused.stopped
- If the instance has stopped (automatically or manually)
MotionChain:
.play()
- Now has an optional boolean parameter which will play the chain in reverse.togglePause()
- Will pause and resume whatever animation in the chain is currently playing
- Engine: Fixed a bug where if you had multiple animations running and one of them finished, the animation that was registered immediately after the one that finished would skip 1 frame.
- Motion: Fixed a bug where you could trigger and animation start while it was already running causing some interesting results
- Initial Release