UNPKG

wot-design

Version:

Mobile UI components built on vue.js

16 lines (12 loc) 309 B
export default ($el, to, duration) => { let count = 0 const from = $el.scrollLeft const frames = duration === 0 ? 1 : Math.round(duration / 16) function animate () { $el.scrollLeft += (to - from) / frames if (++count < frames) { requestAnimationFrame(animate) } } animate() }