Comparing version 0.1.2 to 0.1.3
@@ -29,2 +29,20 @@ 'use strict'; | ||
function blender(easing, reverse) { | ||
if (typeof easing === 'function') { | ||
return function (t) { | ||
return [reverse ? 1 - easing(t) : 0 + easing(t)]; | ||
}; | ||
} | ||
return function (t) { | ||
var result = []; | ||
for (var i = 0, n = easing.length; i < n; i++) { | ||
result.push(reverse ? 1 - easing[i](t) : 0 + easing[i](t)); | ||
} | ||
return result; | ||
}; | ||
} | ||
var Stepper = function () { | ||
@@ -111,7 +129,3 @@ function Stepper() { | ||
var duration = this.duration; | ||
var easing = this.reverse ? function (n) { | ||
return 1 - _this.easing(n); | ||
} : function (n) { | ||
return 0 + _this.easing(n); | ||
}; | ||
var blend = blender(this.easing, this.reverse); | ||
var startTime = 0; | ||
@@ -134,3 +148,3 @@ | ||
_this.status.stop(); | ||
_this.emitter.emit('update', easing(1)); | ||
_this.emitter.emit.apply(_this.emitter, ['update'].concat(blend(1))); | ||
_this.emitter.emit('ended'); | ||
@@ -142,3 +156,3 @@ | ||
_this.emitter.emit('update', easing(progress)); | ||
_this.emitter.emit.apply(_this.emitter, ['update'].concat(blend(progress))); | ||
@@ -145,0 +159,0 @@ _this.pastTime = pastTime; |
{ | ||
"name": "stepperjs", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "A tiny requestAnimationFrame wrapper to improve usability.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -18,3 +18,3 @@ # StepperJS | ||
for Babel | ||
#### for Babel | ||
@@ -41,6 +41,47 @@ ```js | ||
for Browser | ||
If you want to change options after creating the object | ||
```js | ||
const stepper = new Stepper(); | ||
stepper.option('duration', 500); | ||
stepper.option('easing', linear); | ||
stepper.option('loop', false); | ||
stepper.option('reverse', false); | ||
// or | ||
stepper.option({ | ||
duration: 500, | ||
easing: linear, | ||
loop: false, | ||
reverse: false | ||
}); | ||
``` | ||
If you want to use multiple easing function. | ||
```js | ||
import Stepper from 'stepperjs'; | ||
import linear from 'stepperjs/dist/easings/linear'; | ||
import inBack from 'stepperjs/dist/easings/inBack'; | ||
const stepper = new Stepper({ | ||
duration: 300, | ||
easing: [linear, inBack] | ||
}).on({ | ||
update: (n1, n2) => { | ||
console.log(n1); // value of linear | ||
console.log(n2); // value of inBack | ||
} | ||
}); | ||
stepper.start(); | ||
``` | ||
#### for Browser | ||
```html | ||
<script type="text/javascript" src="stepperjs.browser-0.1.2.min.js"></script> | ||
<script type="text/javascript" src="stepperjs.browser-0.1.3.min.js"></script> | ||
``` | ||
@@ -47,0 +88,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
136405
1711
116