Socket
Socket
Sign inDemoInstall

nanotween

Package Overview
Dependencies
1
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.0 to 0.6.0

2

dist/index.js

@@ -1,1 +0,1 @@

var NanoTween=function(){var e,t=(function(e){(e.exports=function(){this.events={}}).prototype={on:function(e,t){return(e=this.events[e]=this.events[e]||[]).push(t),function(){e.splice(e.indexOf(t)>>>0,1)}},emit:function(e){var t=this.events[e];if(t&&t[0]){var n=t.slice.call(arguments,1);t.slice().map(function(e){e.apply(this,n)})}}}}(e={exports:{}},e.exports),e.exports),n=0,s=[];function r(){var e=this,n={id:s.length,delay:0,repeats:1,duration:0,easing:function(e){return e},converters:[]};function r(){return{progress:e.state.progress,value:e.state.value,remaining:e.state.repeats+1,completed:n.repeats-e.state.repeats-1}}function u(t){e.state.progress=t;var s=n.easing;s.reverse=s.reverse||s;var r=e.state.reversed?1-s.reverse(e.state.progress):s(e.state.progress);e.state.value=n.converters.reduce(function(e,t){return t(e)},r),e.bus.emit("update",e.state.value)}e.state={isRunning:!1,current:void 0,progress:0,reversed:!1,repeats:0},e.bus=new t,s.push(e),e.use=function(t){return t(e),e},e.easing=function(t){return n.easing=t,e},e.duration=function(t){return n.duration=t,e},e.delay=function(t){return n.delay=t,e},e.repeat=function(t){return n.repeats=t,e},e.reverse=function(t){return e.state.reversed=void 0!==t?t:!e.state.reversed,e.state.progress=1-e.state.progress,e},e.on=function(t,n){return e.bus.on(t,n),e},e.convert=function(t){return n.converters.push(t),e},e.set=function(t){if(t>1){var n=Math.floor(t);if(e.complete(n),!e.state.isRunning)return;u(t-n)}else u(t);return e},e.tick=function(t){e.set(e.state.progress+t/n.duration)},e.start=function(){return e._i=setTimeout(function(){e.set(0),e.state.repeats=n.repeats-1,e.state.isRunning=!0,e.bus.emit("start")},n.delay),e},e.stop=function(){return e.set(1),e.state.repeats=0,e.state.isRunning=!1,e.bus.emit("stop"),e},e.complete=function(t){u(1);for(var n=e.state.repeats<t,s=n?e.state.repeats:t;s>0;)e.state.repeats--,e.bus.emit("step",s),s--;return n&&(e.state.isRunning=!1,e.bus.emit("complete")),e},e.play=function(){return e.state.isRunning=!0,e.bus.emit("play",r()),e},e.pause=function(){return e.state.isRunning=!1,e.bus.emit("pause",r()),e}}return r.update=function(e){document.hidden||(s.forEach(function(t){t.state.isRunning&&t.tick(e-n)}),n=e)},r}();
var NanoTween=function(){var e,t=(function(e){(e.exports=function(){this.events={}}).prototype={on:function(e,t){return(e=this.events[e]=this.events[e]||[]).push(t),function(){e.splice(e.indexOf(t)>>>0,1)}},emit:function(e){var t=this.events[e];if(t&&t[0]){var n=t.slice.call(arguments,1);t.slice().map(function(e){e.apply(this,n)})}}}}(e={exports:{}},e.exports),e.exports),n=0,s=[];function r(){var e=this,n={delay:0,repeats:1,duration:0,easing:function(e){return e},converters:[]};function r(){return{progress:e.state.progress,value:e.state.value,remaining:e.state.repeats+1,completed:n.repeats-e.state.repeats-1}}function i(t){e.state.progress=t;var s=n.easing;s.reverse=s.reverse||s;var r=e.state.reversed?1-s.reverse(e.state.progress):s(e.state.progress);e.state.value=n.converters.reduce(function(e,t){return t(e)},r),e.bus.emit("update",e.state.value)}e.state={id:s.length,isRunning:!1,isRemoved:!1,current:void 0,progress:0,reversed:!1,repeats:0},e.bus=new t,s.push(e),e.use=function(t){return t(e),e},e.easing=function(t){return n.easing=t,e},e.duration=function(t){return n.duration=t,e},e.delay=function(t){return n.delay=t,e},e.repeat=function(t){return n.repeats=t,e},e.reverse=function(t){return e.state.reversed=void 0!==t?t:!e.state.reversed,e.state.progress=1-e.state.progress,e},e.on=function(t,n){return e.bus.on(t,n),e},e.convert=function(t){return n.converters.push(t),e},e.set=function(t){if(t>1){var n=Math.floor(t);if(e.complete(n),!e.state.isRunning)return;i(t-n)}else i(t);return e},e.tick=function(t){e.set(e.state.progress+t/n.duration)},e.start=function(){return e._i=setTimeout(function(){e.set(0),e.state.repeats=n.repeats-1,e.state.isRunning=!0,e.bus.emit("start")},n.delay),e},e.stop=function(){return e.set(1),e.state.repeats=0,e.state.isRunning=!1,e.bus.emit("stop"),e},e.remove=function(){e.state.isRemoved||(s.splice(s.findIndex(function(t){return e.state.id===t.state.id}),1),e.state.isRemoved=!0)},e.complete=function(t){i(1);for(var n=e.state.repeats<t,s=n?e.state.repeats:t;s>0;)e.state.repeats--,e.bus.emit("step",s),s--;return n&&(e.state.isRunning=!1,e.bus.emit("complete")),e},e.play=function(){return e.state.isRunning=!0,e.bus.emit("play",r()),e},e.pause=function(){return e.state.isRunning=!1,e.bus.emit("pause",r()),e}}return r.update=function(e){document.hidden||(s.forEach(function(t){t.state.isRunning&&t.tick(e-n)}),n=e)},r}();

@@ -10,3 +10,2 @@ import NanoEvents from 'nanoevents'

var _options = {
id: tweens.length,
delay: 0,

@@ -44,3 +43,5 @@ repeats: 1,

self.state = {
id: tweens.length,
isRunning: false,
isRemoved: false,
current: void 0,

@@ -131,2 +132,13 @@ progress: 0,

self.remove = function() {
if (self.state.isRemoved) return
tweens.splice(
tweens.findIndex(function(t) {
return self.state.id === t.state.id
}),
1
)
self.state.isRemoved = true
}
self.complete = function(times) {

@@ -133,0 +145,0 @@ _rescale(1)

{
"name": "nanotween",
"version": "0.5.0",
"version": "0.6.0",
"description": "Tiny library for tweening",

@@ -5,0 +5,0 @@ "main": "index.js",

# NanoTween
1.5 KB is quite enough for full-featured and comfortable tweening
~1.5 KB is quite enough for full-featured and comfortable tweening
![image](https://user-images.githubusercontent.com/4208480/34852373-5c445774-f73f-11e7-9dba-9509b3cff954.png)
## Is it small enough?
I made some researches with [bundlephobia](https://bundlephobia.com) and [size-limit](https://github.com/ai/size-limit) and here's what I can say
I made some researches with [bundlephobia](https://bundlephobia.com) and [size-limit](https://github.com/ai/size-limit) and here's what I can say
> **For now, NanoTween core is the smallest tweening core on NPM**
```

@@ -23,4 +26,5 @@ library ¦ size

anim ¦ 1.1 KB
nanotween ¦ 754 B
nanotween ¦ 848 B
```
## Included features

@@ -27,0 +31,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc