Socket
Socket
Sign inDemoInstall

stepperjs

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stepperjs - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

dist/Status.js

80

dist/Stepper.js

@@ -13,2 +13,6 @@ 'use strict';

var _Status = require('./Status');
var _Status2 = _interopRequireDefault(_Status);
var _linear = require('./easings/linear');

@@ -27,3 +31,5 @@

this.rafId = 0;
this.stopped = null;
this.pastTime = 0;
this.status = new _Status2.default();
this.fnStopped = null;
}

@@ -44,4 +50,6 @@

* loop: true,
* reverse: true,
* start: () => ... ,
* doing: (n) => ... ,
* paused = () => ... ,
* ended: () => ... ,

@@ -65,2 +73,4 @@ * stopped: () => ...

loop = _options$loop === undefined ? false : _options$loop,
_options$reverse = options.reverse,
reverse = _options$reverse === undefined ? false : _options$reverse,
_options$start = options.start,

@@ -70,2 +80,4 @@ start = _options$start === undefined ? function () {} : _options$start,

doing = _options$doing === undefined ? function () {} : _options$doing,
_options$paused = options.paused,
paused = _options$paused === undefined ? function () {} : _options$paused,
_options$ended = options.ended,

@@ -77,23 +89,40 @@ ended = _options$ended === undefined ? function () {} : _options$ended,

if (!duration) {
if (duration === 0 || this.status.isPlaying()) {
return;
}
this.stopped = stopped;
this.fnStopped = stopped;
if (this.rafId) {
this.stop();
}
var end = +new Date() + duration;
var getNow = reverse ? function (time) {
return 1 - easing(time);
} : function (time) {
return 0 + easing(time);
};
var startTime = +new Date() - this.pastTime;
var stepping = function stepping() {
var remaining = end - +new Date();
var time = remaining / duration;
var pastTime = +new Date() - startTime;
var progress = pastTime / duration;
if (remaining < 0) {
ended();
if (_this.status.isPaused()) {
// Cache past time for replay.
_this.pastTime = pastTime;
_this.rafId = 0;
end = +new Date() + duration;
if (!loop) {
_raf2.default.cancel(_this.rafId);
paused();
return;
}
if (pastTime >= duration) {
if (loop) {
startTime = +new Date();
} else {
_this.pastTime = 0;
_this.rafId = 0;
_this.status.toStop();
ended();
return;

@@ -103,6 +132,8 @@ }

doing(1 - easing(time));
doing(getNow(progress));
_this.rafId = (0, _raf2.default)(stepping);
};
this.status.toPlay();
start();

@@ -112,13 +143,18 @@ stepping();

}, {
key: 'pause',
value: function pause() {
this.status.toPause();
}
}, {
key: 'stop',
value: function stop() {
if (!this.rafId) {
return;
}
if (this.status.toStop()) {
_raf2.default.cancel(this.rafId);
_raf2.default.cancel(this.rafId);
this.rafId = 0;
this.pastTime = 0;
this.rafId = 0;
if (this.stopped) {
this.stopped();
if (this.fnStopped) {
this.fnStopped();
}
}

@@ -125,0 +161,0 @@ }

{
"name": "stepperjs",
"version": "0.0.1",
"version": "0.0.2",
"description": "A tiny requestAnimationFrame wrapper to improve usability.",

@@ -38,2 +38,3 @@ "main": "dist/index.js",

"babel-plugin-transform-es3-property-literals": "6.8.0",
"babel-plugin-transform-inline-environment-variables": "^6.8.0",
"babel-preset-es2015": "6.18.0",

@@ -40,0 +41,0 @@ "babel-preset-es2015-loose": "8.0.0",

@@ -27,4 +27,6 @@ # StepperJS

loop: true, // default: false
reverse: true, // default: false
start: () => ... ,
doing: (n) => ... ,
paused: () => ... ,
ended: () => ... ,

@@ -34,2 +36,3 @@ stopped: () => ...

stepper.pause();
stepper.stop();

@@ -41,3 +44,3 @@ ```

```html
<script type="text/javascript" src="stepperjs.browser-0.0.1.min.js"></script></head>
<script type="text/javascript" src="stepperjs.browser-0.0.2.min.js"></script></head>
```

@@ -52,4 +55,6 @@

loop: true,
reverse: true,
start: function () { ... },
doing: function (n) { ... },
paused: function () { ... },
ended: function () { ... },

@@ -59,2 +64,3 @@ stopped: function () { ... }

stepper.pause();
stepper.stop();

@@ -61,0 +67,0 @@ ```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc