Comparing version 0.0.2 to 0.0.3
@@ -15,50 +15,26 @@ "use strict"; | ||
this.toStop(); | ||
this.stopped = true; | ||
this.paused = false; | ||
} | ||
_createClass(Status, [{ | ||
key: "toPlay", | ||
value: function toPlay() { | ||
if (this.isPlaying()) { | ||
return false; | ||
} | ||
this.pending = false; | ||
key: "play", | ||
value: function play() { | ||
this.stopped = false; | ||
this.paused = false; | ||
return true; | ||
} | ||
}, { | ||
key: "toPause", | ||
value: function toPause() { | ||
if (this.isPending()) { | ||
return false; | ||
} | ||
this.pending = true; | ||
key: "pause", | ||
value: function pause() { | ||
this.paused = true; | ||
return true; | ||
} | ||
}, { | ||
key: "toStop", | ||
value: function toStop() { | ||
if (this.isStopped()) { | ||
return false; | ||
} | ||
this.pending = true; | ||
this.paused = false; | ||
return true; | ||
key: "stop", | ||
value: function stop() { | ||
this.stopped = true; | ||
} | ||
}, { | ||
key: "isPending", | ||
value: function isPending() { | ||
return this.pending; | ||
} | ||
}, { | ||
key: "isPlaying", | ||
value: function isPlaying() { | ||
return !this.pending; | ||
return !this.stopped && !this.paused; | ||
} | ||
@@ -73,3 +49,3 @@ }, { | ||
value: function isStopped() { | ||
return this.isPending() && !this.isPaused(); | ||
return this.stopped; | ||
} | ||
@@ -76,0 +52,0 @@ }]); |
@@ -32,2 +32,3 @@ 'use strict'; | ||
this.status = new _Status2.default(); | ||
this.fnPaused = null; | ||
this.fnStopped = null; | ||
@@ -89,2 +90,3 @@ } | ||
this.fnPaused = paused; | ||
this.fnStopped = stopped; | ||
@@ -102,13 +104,2 @@ | ||
if (_this.status.isPaused()) { | ||
// Cache past time for replay. | ||
_this.pastTime = pastTime; | ||
_this.rafId = 0; | ||
_raf2.default.cancel(_this.rafId); | ||
paused(); | ||
return; | ||
} | ||
if (pastTime >= duration) { | ||
@@ -120,5 +111,4 @@ if (loop) { | ||
_this.rafId = 0; | ||
_this.status.stop(); | ||
_this.status.toStop(); | ||
ended(); | ||
@@ -131,6 +121,8 @@ | ||
doing(getNow(progress)); | ||
_this.pastTime = pastTime; | ||
_this.rafId = (0, _raf2.default)(stepping); | ||
}; | ||
this.status.toPlay(); | ||
this.status.play(); | ||
@@ -143,3 +135,14 @@ start(); | ||
value: function pause() { | ||
this.status.toPause(); | ||
if (this.status.isPaused()) { | ||
return; | ||
} | ||
_raf2.default.cancel(this.rafId); | ||
this.rafId = 0; | ||
this.status.pause(); | ||
if (this.fnPaused) { | ||
this.fnPaused(); | ||
} | ||
} | ||
@@ -149,11 +152,14 @@ }, { | ||
value: function stop() { | ||
if (this.status.toStop()) { | ||
_raf2.default.cancel(this.rafId); | ||
if (this.status.isStopped()) { | ||
return; | ||
} | ||
this.pastTime = 0; | ||
this.rafId = 0; | ||
_raf2.default.cancel(this.rafId); | ||
if (this.fnStopped) { | ||
this.fnStopped(); | ||
} | ||
this.pastTime = 0; | ||
this.rafId = 0; | ||
this.status.stop(); | ||
if (this.fnStopped) { | ||
this.fnStopped(); | ||
} | ||
@@ -160,0 +166,0 @@ } |
{ | ||
"name": "stepperjs", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A tiny requestAnimationFrame wrapper to improve usability.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -42,3 +42,3 @@ # StepperJS | ||
```html | ||
<script type="text/javascript" src="stepperjs.browser-0.0.2.min.js"></script></head> | ||
<script type="text/javascript" src="stepperjs.browser-0.0.3.min.js"></script></head> | ||
``` | ||
@@ -45,0 +45,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
105535
1377