<script src="path/to/weee.pkgd.js"></script>
weee.pkgd.js is packaged file with dependencies (EventEmitter2). If you already have EventEmitter2 in your project, use weee.js.
npm install weee
var target = document.getElementById('target');
weee({
from: 0,
to: 500,
duration: 2000,
ease: weee.cubicInOut,
target: target,
setter: weee.Tween.css({name: 'left', unit: 'px'})
})
.play();
var target = document.getElementById('target');
weee({
from: 0,
to: 500,
duration: 2000,
ease: weee.cubicInOut,
repeatType: 'reverse',
repeatCount: Infinity,
target: target,
setter: weee.Tween.css({name: 'left', unit: 'px'})
})
.play();
var target = document.getElementById('target');
weee({
from: 0,
to: 1,
duration: 2000,
ease: weee.cubicInOut,
target: target,
setter: function(value) {
// `this` is set to the target
this.style.left = String(value * 500) + 'px';
this.style.top = String(value * 300) + 'px';
}
})
.play();
var target = document.getElementById('target');
weee({
from: 0,
to: 500,
duration: 2000,
ease: weee.cubicInOut
})
.on('start', function(tween) {
console.log('start', tween.value());
})
.on('update', function(tween) {
console.log('update', tween.value());
target.style.left = String(tween.value()) + 'px';
})
.on('end', function(tween) {
console.log('end', tween.value());
})
.play();
weee()
.from(0)
.to(500)
.duration(2000)
.ease(weee.cubicInOut)
.target(target)
.setter(weee.Tween.css({name: 'left', unit: 'px'}))
.play();
var t = weee.ScrollY({
duration: 500,
ease: weee.cubicOut,
target: window
});
t.to(1000);