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

animated-scroll

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

animated-scroll - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

bower.json
{
"name": "animated-scroll",
"version": "0.0.1",
"version": "0.0.3",
"description": "Programmatic scrolling as an angular service",

@@ -5,0 +5,0 @@ "main": "dist/AnimatedScroll.js",

/**
* animated-scroll
* Version: 0.0.1
* (c) 2016 Joel Mukuthu
* Version: 0.0.3
* (c) 2019 Joel Mukuthu
* MIT License
* Built on: 17-11-2016 18:05:38 GMT+0100
* Built on: 07-12-2019 12:54:04 GMT+0100
**/

@@ -108,6 +108,6 @@

if (typeof number !== 'number' || isNaN(number)) {
throw new Error(name + ' (' + number + ') should be a number');
throw new Error(name + ' should be a number');
}
if (number < 0) {
throw new Error(name + ' (' + number + ') should be greater than zero');
throw new Error(name + ' should be greater than or equal to zero');
}

@@ -122,2 +122,6 @@ };

if (!element) {
throw new Error('provide a DOM element');
}
if ((typeof element === 'undefined' ? 'undefined' : _typeof(element)) !== 'object' || typeof element.nodeName !== 'string') {

@@ -146,4 +150,7 @@ throw new Error('the element should be a DOM element');

var easing = options.easing;
if (typeof easing !== 'undefined' && typeof easing !== 'function') {
throw new Error('the easing option should be a function');
if (typeof easing !== 'undefined') {
if (typeof easing !== 'function') {
throw new Error('the easing option should be a function');
}
this.easing = easing;
} else {

@@ -166,3 +173,3 @@ this.easing = easeInOutQuad;

if (duration !== false) {
return validatePositiveNumber(duration, 'duration');
validatePositiveNumber(duration, 'duration');
}

@@ -182,3 +189,3 @@ if (typeof easing !== 'function') {

elementProperty = 'scrollLeft';
animationProperty = 'topAnimation';
animationProperty = 'leftAnimation';

@@ -199,3 +206,4 @@ _this.stopLeft();

duration = parseInt(duration);
duration = parseInt(duration, 10); // you want to use radix 10
// so you get a decimal number even with a leading 0 and an old browser ([IE8, Firefox 20, Chrome 22 and older][1])

@@ -223,2 +231,3 @@ var currentTime = 0;

};
animate();
});

@@ -225,0 +234,0 @@ }

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

/* animated-scroll v0.0.1, (c) 2016 Joel Mukuthu, MIT License, built: 17-11-2016 18:05:38 GMT+0100 */
!function(a,b){if("function"==typeof define&&define.amd)define(["module","exports"],b);else if("undefined"!=typeof exports)b(module,exports);else{var c={exports:{}};b(c,c.exports),a.AnimatedScroll=c.exports}}(this,function(a,b){"use strict";function c(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(b,"__esModule",{value:!0});var d=function(){function a(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!b||c.length!==b);d=!0);}catch(i){e=!0,f=i}finally{try{!d&&h["return"]&&h["return"]()}finally{if(e)throw f}}return c}return function(b,c){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return a(b,c);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},f=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),g=function(a,b,c,d){return a/=d/2,a<1?c/2*a*a+b:(a--,-c/2*(a*(a-2)-1)+b)},h=function(a,b){if("number"!=typeof a||isNaN(a))throw new Error(b+" ("+a+") should be a number");if(a<0)throw new Error(b+" ("+a+") should be greater than zero")},i=function(){function a(b){var d=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(c(this,a),"object"!==("undefined"==typeof b?"undefined":e(b))||"string"!=typeof b.nodeName)throw new Error("the element should be a DOM element");this.element=b;var f=d.timeIncrement;"undefined"!=typeof f?(h(f,"the timeIncrement option"),this.timeIncrement=f):this.timeIncrement=20;var i=d.duration;"undefined"!=typeof i&&i!==!1?(h(i,"the duration option"),this.duration=i):this.duration=400;var j=d.easing;if("undefined"!=typeof j&&"function"!=typeof j)throw new Error("the easing option should be a function");this.easing=g}return f(a,[{key:"_scroll",value:function(a,b){var c=this,d=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.duration,e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.easing;return new Promise(function(f){if(h(b,a),d!==!1)return h(d,"duration");if("function"!=typeof e)throw new Error("easing should be a function");var g=void 0,i=void 0;if("top"===a?(g="scrollTop",i="topAnimation",c.stopTop()):(g="scrollLeft",i="topAnimation",c.stopLeft()),b=parseFloat(b),!d)return c.element[g]=b,f(c.element[g]);c.element[g],c.timeIncrement;d=parseInt(d)})}},{key:"top",value:function(a,b,c){return this._scroll("top",a,b,c)}},{key:"left",value:function(a,b,c){return this._scroll("left",a,b,c)}},{key:"to",value:function(a,b,c){var e=a.top,f=a.left;return void 0===e?this.left(f,b,c):void 0===f?this.top(e,b,c):Promise.all([this.top(e,b,c),this.left(f,b,c)]).then(function(a){var b=d(a,2),c=b[0],e=b[1];return{top:c,left:e}})}},{key:"_stop",value:function(a){var b="top"===a?this.topAnimation:this.leftAnimation;b&&cancelAnimationFrame(b)}},{key:"stopTop",value:function(){return this._stop("top")}},{key:"stopLeft",value:function(){return this._stop("left")}},{key:"stop",value:function(){this.stopTop(),this.stopLeft()}}]),a}();b["default"]=i,a.exports=b["default"]});
/* animated-scroll v0.0.3, (c) 2019 Joel Mukuthu, MIT License, built: 07-12-2019 12:54:04 GMT+0100 */
!function(a,b){if("function"==typeof define&&define.amd)define(["module","exports"],b);else if("undefined"!=typeof exports)b(module,exports);else{var c={exports:{}};b(c,c.exports),a.AnimatedScroll=c.exports}}(this,function(a,b){"use strict";function c(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(b,"__esModule",{value:!0});var d=function(){function a(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!b||c.length!==b);d=!0);}catch(i){e=!0,f=i}finally{try{!d&&h["return"]&&h["return"]()}finally{if(e)throw f}}return c}return function(b,c){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return a(b,c);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},f=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),g=function(a,b,c,d){return a/=d/2,a<1?c/2*a*a+b:(a--,-c/2*(a*(a-2)-1)+b)},h=function(a,b){if("number"!=typeof a||isNaN(a))throw new Error(b+" should be a number");if(a<0)throw new Error(b+" should be greater than or equal to zero")},i=function(){function a(b){var d=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(c(this,a),!b)throw new Error("provide a DOM element");if("object"!==("undefined"==typeof b?"undefined":e(b))||"string"!=typeof b.nodeName)throw new Error("the element should be a DOM element");this.element=b;var f=d.timeIncrement;"undefined"!=typeof f?(h(f,"the timeIncrement option"),this.timeIncrement=f):this.timeIncrement=20;var i=d.duration;"undefined"!=typeof i&&i!==!1?(h(i,"the duration option"),this.duration=i):this.duration=400;var j=d.easing;if("undefined"!=typeof j){if("function"!=typeof j)throw new Error("the easing option should be a function");this.easing=j}else this.easing=g}return f(a,[{key:"_scroll",value:function(a,b){var c=this,d=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.duration,e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.easing;return new Promise(function(f){if(h(b,a),d!==!1&&h(d,"duration"),"function"!=typeof e)throw new Error("easing should be a function");var g=void 0,i=void 0;if("top"===a?(g="scrollTop",i="topAnimation",c.stopTop()):(g="scrollLeft",i="leftAnimation",c.stopLeft()),b=parseFloat(b),!d)return c.element[g]=b,f(c.element[g]);var j=c.element[g],k=b-j,l=c.timeIncrement;d=parseInt(d,10);var m=0,n=function o(){m+=l;var b=e(m,j,k,d);try{h(b)}catch(n){throw c._stop(a),n.message+=" (check your easing function)",n}c.element[g]=b,m<d?c[i]=requestAnimationFrame(o,l):f(c.element[g])};n()})}},{key:"top",value:function(a,b,c){return this._scroll("top",a,b,c)}},{key:"left",value:function(a,b,c){return this._scroll("left",a,b,c)}},{key:"to",value:function(a,b,c){var e=a.top,f=a.left;return void 0===e?this.left(f,b,c):void 0===f?this.top(e,b,c):Promise.all([this.top(e,b,c),this.left(f,b,c)]).then(function(a){var b=d(a,2),c=b[0],e=b[1];return{top:c,left:e}})}},{key:"_stop",value:function(a){var b="top"===a?this.topAnimation:this.leftAnimation;b&&cancelAnimationFrame(b)}},{key:"stopTop",value:function(){return this._stop("top")}},{key:"stopLeft",value:function(){return this._stop("left")}},{key:"stop",value:function(){this.stopTop(),this.stopLeft()}}]),a}();b["default"]=i,a.exports=b["default"]});
{
"name": "animated-scroll",
"version": "0.0.2",
"version": "0.0.3",
"description": "Animate scrollTop and scrollLeft",

@@ -22,21 +22,21 @@ "main": "dist/AnimatedScroll.js",

"devDependencies": {
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-istanbul": "^3.0.0",
"babel-plugin-add-module-exports": "^1.0.0",
"babel-plugin-istanbul": "^5.1.1",
"babel-plugin-transform-es2015-modules-umd": "^6.18.0",
"babel-preset-es2015": "^6.18.0",
"coveralls": "^2.11.15",
"cross-env": "^3.1.3",
"eslint": "^3.10.2",
"coveralls": "^3.0.1",
"cross-env": "^5.0.0",
"eslint": "^5.0.0",
"grunt": "^1.0.1",
"grunt-babel": "^6.0.0",
"grunt-banner": "^0.6.0",
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-uglify": "^1.0.2",
"grunt-contrib-clean": "^2.0.0",
"grunt-contrib-uglify": "^4.0.0",
"grunt-release-it": "^1.0.1",
"jsdom": "^9.8.3",
"jsdom-global": "^2.1.0",
"load-grunt-tasks": "^3.5.0",
"mocha": "^3.1.2",
"nyc": "^9.0.1",
"unexpected": "^10.13.3"
"jsdom": "^13.0.0",
"jsdom-global": "^3.0.2",
"load-grunt-tasks": "^4.0.0",
"mocha": "^6.0.0",
"nyc": "^14.0.0",
"unexpected": "^11.0.1"
},

@@ -43,0 +43,0 @@ "babel": {

# animated-scroll
[![Greenkeeper badge](https://badges.greenkeeper.io/joelmukuthu/animated-scroll.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/joelmukuthu/animated-scroll.svg?branch=master)](https://travis-ci.org/joelmukuthu/animated-scroll) [![Licence](https://img.shields.io/npm/l/animated-scroll.svg)](https://github.com/joelmukuthu/animated-scroll/blob/master/LICENSE.md) [![Coverage Status](https://coveralls.io/repos/github/joelmukuthu/animated-scroll/badge.svg?branch=master)](https://coveralls.io/github/joelmukuthu/animated-scroll?branch=master) [![Bower version](https://img.shields.io/bower/v/animated-scroll.svg)](https://github.com/joelmukuthu/animated-scroll) [![npm version](https://img.shields.io/npm/v/animated-scroll.svg)](https://www.npmjs.com/package/animated-scroll)

@@ -6,4 +8,3 @@

`requestAnimationFrame` to provide smooth animations and returns a `Promise` to
notify when the animation is completed. To ensure compatibility with older
browsers, add polyfills for `requestAnimationFrame` and `Promise` as needed.
notify when the animation is completed.

@@ -28,7 +29,7 @@ ### Installation

```javascript
var AnimatedScroll = require('dist/AnimatedScroll.min.js');
var AnimatedScroll = require('animated-scroll');
// or
import AnimatedScroll from 'dist/AnimatedScroll.min.js';
import AnimatedScroll from 'animated-scroll';
// or
define([ 'dist/AnimatedScroll.min.js' ], function (AnimatedScroll) {});
define([ 'path/to/animated-scroll' ], function (AnimatedScroll) {});
// or

@@ -53,6 +54,3 @@ var AnimatedScroll = window.AnimatedScroll;

scroll.to({
left: 100,
top: 100
}).then(function (coords) {
scroll.to({ left: 100, top: 100 }).then(function (coords) {
console.log('#myElement\'s scrollTop is now', coords.top);

@@ -59,0 +57,0 @@ console.log('#myElement\'s scrollLeft is now', coords.left);

@@ -79,3 +79,3 @@ const easeInOutQuad = (time, start, change, duration) => {

elementProperty = 'scrollLeft';
animationProperty = 'topAnimation';
animationProperty = 'leftAnimation';

@@ -82,0 +82,0 @@ this.stopLeft();

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