Releases: jeremyckahn/shifty
Hotfix for 2.13.1
Fixes an unsafe method reference: fe485ce
Prevent multiple Date.now calls per tick
A teeny-tiny release that won't affect most folks. It'll make animation timing slightly more accurate for animations with a very large number of synchronized tweens (as in, thousands).
Performance improvements
This release makes Shifty faster. It significantly reduces memory overhead by reusing objects and variables instead of re-declaring and initializing them.
The only functional change is trivial, but may potentially result in harmless warnings in some environments (specifically Node): e277dc7
If you see a warning in Node, simply add a .catch()
to the Tween Promise
or wrap it in a try
/catch
(which is a good practice for Promises generally).
Diff: v2.12.0...v2.13.0
Add .cancel() and .data() methods
const { Tweenable } = shifty
const tweenable = new Tweenable()
;(async () => {
const element = document.querySelector('#tweenable')
while (true) {
try {
await tweenable.tween({
render: ({ x }) => {
element.style.transform = `translateX(${x}px)`
},
data: { hello: 'world' },
easing: 'easeInOutQuad',
duration: 400,
from: { x: 0 },
to: { x: 200 },
})
await tweenable.tween({
to: { x: 0 },
})
} catch (e) {
console.log(e.tweenable.data())
break
}
}
})()
document.querySelector('#cancel').addEventListener('click', () => {
tweenable.cancel()
})
See:
Fix compatibility bug introduced by 2.11.0
Fixes a compatibility bug introduced by https://github.com/jeremyckahn/shifty/releases/tag/2.11.0.
Improved async/await support and property names
Shifty 2.11.0
improves support for async
/await
. Now code like this can be written:
import { tween } from 'shifty'
const animate = async () => {
const element = document.querySelector('#tweenable')
const { tweenable } = await tween({
render: ({ scale, x }) => {
element.style.transform = `translateX(${x}px) scale(${scale})`
},
easing: 'easeInOutQuad',
duration: 500,
from: { scale: 1, x: 0 },
to: { x: 200 },
})
await tweenable.tween({
to: { x: 0 },
})
await tweenable.tween({
to: { scale: 3 },
})
}
This release also changes how tweens resolve, implicitly reuses config across tweens, renames step
to render
and attachment
to data
(with legacy property names supported).
See:
Remove promise rejection
Fixes #117
This release fixes the infinite loop bug discovered by @kylewetton: #117
[BREAKING CHANGE] Improve error message when stop is called
v2.9.0 incorporates #115 to improve how tweens are reject
ed.
Specifically, it changes a tween's Promise reject
callback signature from:
/**
* @param {Object} currentState
* @param {Object} attachment
*/
reject(currentState, attachment)
to
/**
* @param {Object} data
* @param {Object} data.currentState
* @param {Object} data.attachment
* @param {string} data.error
*/
reject(data)
Fixes node support
The toolchain updates in 2.7.0
broke Node compatibility. This release fixes that.