Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

animazione

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

animazione - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

index.js

8

dist/animazione.js

@@ -76,3 +76,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 2);
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })

@@ -85,3 +85,3 @@ /************************************************************************/

"use strict";
var _Mathsin=Math.sin,_MathPI=Math.PI,_Mathpow=Math.pow;Object.defineProperty(exports,"__esModule",{value:!0});var easeIn=function(a){return function(b){return _Mathpow(b,a)}},easeOut=function(a){return function(b){return 1-Math.abs(_Mathpow(b-1,a))}},easeInOut=function(a){return function(b){return 0.5>b?easeIn(a)(2*b)/2:easeOut(a)(2*b-1)/2+0.5}},easing={linear:function linear(a){return a},easeInQuad:easeIn(2),easeOutQuad:easeOut(2),easeInOutQuad:easeInOut(2),easeInCubic:easeIn(3),easeOutCubic:easeOut(3),easeInOutCubic:easeInOut(3),easeInQuart:easeIn(4),easeOutQuart:easeOut(4),easeInOutQuart:easeInOut(4),easeInQuint:easeIn(5),easeOutQuint:easeOut(5),easeInOutQuint:easeInOut(5),easeInSin:function easeInSin(a){return 1+_Mathsin(_MathPI/2*a-_MathPI/2)},easeOutSin:function easeOutSin(a){return _Mathsin(_MathPI/2*a)},easeInOutSin:function easeInOutSin(a){return(1+_Mathsin(_MathPI*a-_MathPI/2))/2}};exports.default=easing;
var _createClass=function(){function a(b,c){for(var e,d=0;d<c.length;d++)e=c[d],e.enumerable=e.enumerable||!1,e.configurable=!0,'value'in e&&(e.writable=!0),Object.defineProperty(b,e.key,e)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}var _require=__webpack_require__(2),raf=_require.raf,caf=_require.caf,TIME_TOLERANCE=8,noop=function(){},linearEasing=function(a){return a},Animazione=function(){function a(){var b=this,c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:noop,d=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,a);var e=d.target,f=void 0===e?null:e,g=d.duration,h=void 0===g?0:g,j=d.initialValue,k=void 0===j?0:j,l=d.endValue,m=void 0===l?100:l,n=d.easing,o=void 0===n?linearEasing:n,p=d.fps,q=void 0===p?60:p,r=d.onComplete,s=void 0===r?noop:r;this._initialValue=k,this._endValue=m,this._easing='function'==typeof o?o:linearEasing,this._value=k,this._frameDuration=1e3/q,this._framesCount=h/this._frameDuration,this._currentFrame=0,this._lastTime=0,this._delta=m-k,this._target=f,this._render=c.bind(f),this._onComplete=s.bind(f),this._tick=function(u){return b._lastTime=u||0,(!b._lastTime||u>=b._nextTime-TIME_TOLERANCE)&&(b._nextTime=b._lastTime+b._frameDuration,b._updateValue(),b._render(b._value),b._value>=b._endValue)?void b._onComplete():void(b._id=raf(b._tick))}}return _createClass(a,[{key:'_updateValue',value:function _updateValue(){if(this._currentFrame++,this._currentFrame>=this._framesCount)this._value=this._endValue;else{var b=this._initialValue+this._delta*this._easing(this._currentFrame/this._framesCount);this._value=b>=this._endValue?this._endValue:b}}},{key:'start',value:function start(){this._tick()}},{key:'stop',value:function stop(){this._id&&(caf(this._id),this._onComplete())}}]),a}();module.exports=Animazione;

@@ -93,3 +93,3 @@ /***/ }),

"use strict";
Object.defineProperty(exports,'__esModule',{value:!0});var canUseDom=!!('undefined'!=typeof window&&window.document&&window.document.createElement),raf=exports.raf=canUseDom?window.requestAnimationFrame:function(){},caf=exports.caf=canUseDom?window.cancelAnimationFrame:function(){};
var Animazione=__webpack_require__(0);module.exports=Animazione;

@@ -101,3 +101,3 @@ /***/ }),

"use strict";
var _createClass=function(){function a(b,c){for(var e,d=0;d<c.length;d++)e=c[d],e.enumerable=e.enumerable||!1,e.configurable=!0,'value'in e&&(e.writable=!0),Object.defineProperty(b,e.key,e)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_easing=__webpack_require__(0),_easing2=_interopRequireDefault(_easing),_requestAnimationFrame=__webpack_require__(1);function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}var TIME_TOLERANCE=8,noop=function(){},Animazione=function(){function a(){var b=this,c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:noop,d=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,a);var e=d.target,f=void 0===e?null:e,g=d.duration,h=void 0===g?0:g,j=d.initialValue,k=void 0===j?0:j,l=d.endValue,m=void 0===l?100:l,n=d.easing,o=void 0===n?_easing2.default.linear:n,p=d.fps,q=void 0===p?60:p;this._initialValue=k,this._endValue=m,'function'==typeof o&&(this._easing=o),'string'==typeof o&&(this._easing=_easing2.default[o]),this._value=k,this._frameDuration=1e3/q,this._framesCount=h/this._frameDuration,this._currentFrame=0,this._lastTime=0,this._delta=m-k,this._target=f,this._render=c.bind(f),this._tick=function(r){b._lastTime=r||0,(!b._lastTime||r>=b._nextTime-TIME_TOLERANCE)&&(b._nextTime=b._lastTime+b._frameDuration,b._updateValue(),b._render(b._value),b._value>=b._endValue)||(b._id=(0,_requestAnimationFrame.raf)(b._tick))}}return _createClass(a,[{key:'_updateValue',value:function _updateValue(){if(this._currentFrame++,this._currentFrame>=this._framesCount)this._value=this._endValue;else{var b=this._initialValue+this._delta*this._easing(this._currentFrame/this._framesCount);this._value=b>=this._endValue?this._endValue:b}}},{key:'start',value:function start(){this._tick()}},{key:'stop',value:function stop(){this._id&&(0,_requestAnimationFrame.caf)(this._id)}}]),a}();module.exports=Animazione;
var canUseDom=!!('undefined'!=typeof window&&window.document&&window.document.createElement),raf=canUseDom?window.requestAnimationFrame:function(){},caf=canUseDom?window.cancelAnimationFrame:function(){};module.exports={raf:raf,caf:caf};

@@ -104,0 +104,0 @@ /***/ })

{
"name": "animazione",
"version": "0.1.1",
"version": "0.1.2",
"description": "simple easing animations using requestAnimationFrame",
"main": "dist/animazione.js",
"main": "index.js",
"scripts": {

@@ -7,0 +7,0 @@ "build": "NODE_ENV=production webpack",

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

import easingFunctions from './easing';
import { raf, caf } from './request-animation-frame';
const { raf, caf } = require('./request-animation-frame');
const TIME_TOLERANCE = 8;
const noop = () => {};
const linearEasing = t => t;

@@ -14,4 +14,5 @@ class Animazione {

endValue = 100,
easing = easingFunctions.linear,
easing = linearEasing,
fps = 60,
onComplete = noop,
} = opts;

@@ -21,4 +22,7 @@

this._endValue = endValue;
if (typeof easing === 'function') this._easing = easing;
if (typeof easing === 'string') this._easing = easingFunctions[easing];
if (typeof easing === 'function') {
this._easing = easing;
} else {
this._easing = linearEasing; // fallback to linear
}
this._value = initialValue;

@@ -32,2 +36,3 @@ this._frameDuration = 1000 / fps;

this._render = render.bind(target);
this._onComplete = onComplete.bind(target);
this._tick = (time) => {

@@ -39,3 +44,6 @@ this._lastTime = time || 0;

this._render(this._value);
if (this._value >= this._endValue) return;
if (this._value >= this._endValue) {
this._onComplete();
return;
}
}

@@ -63,2 +71,3 @@ this._id = raf(this._tick);

caf(this._id);
this._onComplete();
}

@@ -65,0 +74,0 @@ }

const canUseDom = !!((typeof window !== 'undefined'
&& window.document && window.document.createElement));
export const raf = canUseDom ? window.requestAnimationFrame : () => {};
export const caf = canUseDom ? window.cancelAnimationFrame : () => {};
const raf = canUseDom ? window.requestAnimationFrame : () => {};
const caf = canUseDom ? window.cancelAnimationFrame : () => {};
module.exports = {
raf,
caf,
};
const path = require('path');
const config = {
entry: './src/animazione.js',
entry: './index.js',
target: 'web',
output: {

@@ -6,0 +7,0 @@ path: path.resolve(__dirname, 'dist'),

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