Socket
Socket
Sign inDemoInstall

scroll-parallax

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scroll-parallax - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

6

CHANGELOG.md
## Changelog
### 1.0.3
* fixed: destroy method
### 1.0.2
* updated: switched from webpack to rollup to get a cleaner dist code
### 1.0.1

@@ -4,0 +10,0 @@ * added: the parallax `update` event

1

dist/Parallax.js

@@ -479,2 +479,3 @@ (function (global, factory) {

this.off('*');
this.canvases = [];
stage.off('resize', this._onResize).off('scroll', this._onScroll);

@@ -481,0 +482,0 @@ return this;

2

dist/Parallax.min.js

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

!function(t,e){if("function"==typeof define&&define.amd)define("Parallax",["module"],e);else if("undefined"!=typeof exports)e(module);else{var i={exports:{}};e(i),t.Parallax=i.exports}}(this,function(t){"use strict";function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){var i;return i="string"==typeof t?(e||document).querySelectorAll(t):t,Array.prototype.slice.call(i)}function n(t){for(var e,i=arguments,n=1;n<i.length;++n)if(e=i[n])for(var r in e)t[r]=e[r];return t}function r(t){return"undefined"==typeof t}function s(t,e){return e?t.dataset[e]||t.getAttribute("data-"+e):t.dataset||Array.prototype.slice.call(t.attributes).reduce(function(t,e){return/data-/.test(e.name)&&(t[e.name]=e.value),t},{})}function o(t,e,i){for(var n=["ms","o","Moz","webkit",""],r=n.length;r--;){var s=n[r],o=s?s+e[0].toUpperCase()+e.substr(1):e.toLowerCase()+e.substr(1);if(o in t)return t[o]=i,!0}return!1}var a,u=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),h=function(t){t=t||{};var e={},i=Array.prototype.slice,n=function(t,e){t.replace(/\S+/g,e)},r=function(e,i){Object.defineProperty(t,e,{value:i,enumerable:!1,writable:!1,configurable:!1})};return r("on",function(i,r){return"function"!=typeof r?t:(n(i,function(t,i){(e[t]=e[t]||[]).push(r),r.typed=i>0}),t)}),r("off",function(i,r){return"*"!=i||r?n(i,function(t){if(r)for(var i,n=e[t],s=0;i=n&&n[s];++s)i==r&&n.splice(s--,1);else delete e[t]}):e={},t}),r("one",function(e,i){function n(){t.off(e,n),i.apply(t,arguments)}return t.on(e,n)}),r("trigger",function(r){var s,o=i.call(arguments,1);return n(r,function(n){s=i.call(e[n]||[],0);for(var r,a=0;r=s[a];++a){if(r.busy)return;r.busy=1,r.apply(t,r.typed?[n].concat(o):o),s[a]!==r&&a--,r.busy=0}e["*"]&&"*"!=n&&t.trigger.apply(t,["*",n].concat(o))}),t}),t},c=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame||function(t){setTimeout(t,1e3/60)},l=20,f=function(){function t(){e(this,t),h(this),this.resizeTimer=null,this.tick=!1,this.bind()}return u(t,[{key:"bind",value:function(){var t=this;return window.addEventListener("scroll",function(){return t.scroll()},!0),window.addEventListener("mousewheel",function(){return t.scroll()},!0),window.addEventListener("touchmove",function(){return t.scroll()},!0),window.addEventListener("resize",function(){return t.resize()},!0),window.addEventListener("orientationchange",function(){return t.resize()},!0),window.onload=function(){return t.scroll()},this}},{key:"scroll",value:function(){var t=this;return this.tick?this:(this.tick=!this.tick,c(function(){return t.update()}),this)}},{key:"update",value:function(){return this.trigger("scroll",this.scrollTop),this.tick=!this.tick,this}},{key:"resize",value:function(){var t=this;return this.resizeTimer&&clearTimeout(this.resizeTimer),this.resizeTimer=setTimeout(function(){return t.trigger("resize",t.size)},l),this}},{key:"scrollTop",get:function(){var t=(window.pageYOffset||document.scrollTop)-(document.clientTop||0);return window.isNaN(t)?0:t}},{key:"height",get:function(){return window.innerHeight}},{key:"width",get:function(){return window.innerWidth}},{key:"size",get:function(){return{width:this.width,height:this.height}}}]),t}(),d=function(t){return o(t.style,"transform","translate3d(0, 0, 0)"),/translate3d/g.test(t.style.cssText)}(document.createElement("div")),g=function(){function t(i,n){e(this,t),h(this),this.opts=n,this.img=i,this.wrapper=i.parentNode,this.isLoaded=!1}return u(t,[{key:"load",value:function(){var t=this;return this.img.width&&this.img.height&&this.img.complete?this.onImageLoaded():this.img.onload=function(){return t.onImageLoaded()},this}},{key:"onImageLoaded",value:function(){return this.isLoaded=!0,this.update(),this.trigger("loaded",this.img),this}},{key:"update",value:function(){var t=this.img.naturalWidth||this.img.width,e=this.img.naturalHeight||this.img.height,i=t/e,n=this.size;return n.width/i<=n.height?(this.img.height=n.height,this.img.width=n.height*i):(this.img.width=n.width,this.img.height=n.width/i),this.img.style.top=-~~((this.img.height-n.height)/2)+"px",this.img.style.left=-~~((this.img.width-n.width)/2)+"px",this}},{key:"draw",value:function(t){var e=this.size,i=(this.offset.top+e.height*this.opts.center+t.height/2-t.scrollTop)/t.height-1;return i*=this.img.height/e.height/2*this.opts.intensity,d?o(this.img.style,"transform","translate3d(0, "+-i+"%, 0)"):o(this.img.style,"transform","translate(0, "+-i+"%)"),this}},{key:"bounds",get:function(){return this.wrapper.getBoundingClientRect()}},{key:"offset",get:function(){return{top:this.wrapper.offsetTop,left:this.wrapper.offsetLeft}}},{key:"size",get:function(){var t=this.bounds;return{height:0|t.height,width:0|t.width}}}]),t}(),m=function(){function t(i){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return e(this,t),h(this),this.opts=n,this.selector=i,this.canvases=[],this.add(i),a||(a=new f),this}return u(t,[{key:"init",value:function(){return this.canvases.length?(this.imagesLoaded=0,this.bind()):console.warn('No images were found with the selector "'+this.selector+'"'),this}},{key:"bind",value:function(){var t=this;return this._onResize=function(){for(var e=arguments.length,i=Array(e),n=0;e>n;n++)i[n]=arguments[n];return t.resize.apply(t,i)},this._onScroll=function(){for(var e=arguments.length,i=Array(e),n=0;e>n;n++)i[n]=arguments[n];return t.scroll.apply(t,i)},a.on("resize",this._onResize),a.on("scroll",this._onScroll),this.canvases.forEach(function(e){e.one("loaded",function(){return t.onCanvasLoaded(e)}),e.load()}),this}},{key:"refresh",value:function(){return this.onResize(a.size).onScroll(a.scrollTop),this}},{key:"onCanvasLoaded",value:function(t){return this.trigger("image:loaded",t.img,t),this.imagesLoaded++,t.draw(a),this.imagesLoaded==this.canvases.length&&this.trigger("images:loaded"),this}},{key:"scroll",value:function(t){for(var e=this.canvases.length,i=this.opts.offsetYBounds,n=a.scrollTop;e--;){var r=this.canvases[e],s=r.size.height,o=r.offset,u=o.top+s-n;r.isLoaded&&u+i>0&&u-i<n+a.height&&(r.draw(a),this.trigger("draw",r.img))}return this.trigger("update",n),this}},{key:"add",value:function(t){return this.canvases=this.canvases.concat(this.createCanvases(i(t))),this}},{key:"remove",value:function(t){var e=this;return i(t).forEach(function(t){for(var i=e.canvases.length;i--;)if(t==e.canvases[i].img){e.canvases.splice(i,1);break}}),this}},{key:"destroy",value:function(){return this.off("*"),a.off("resize",this._onResize).off("scroll",this._onScroll),this}},{key:"resize",value:function(t){for(var e=this.canvases.length;e--;){var i=this.canvases[e];if(!i.isLoaded)return;i.update().draw(a)}return this.trigger("resize"),this}},{key:"createCanvases",value:function(t){var e=this;return t.map(function(t){var i=s(t);return new g(t,{intensity:r(i.intensity)?e.opts.intensity:+i.intensity,center:r(i.center)?e.opts.center:+i.center})})}},{key:"opts",set:function(t){this._defaults={offsetYBounds:50,intensity:30,center:.5},n(this._defaults,t)},get:function(){return this._defaults}}]),t}();t.exports=m});
!function(t,e){if("function"==typeof define&&define.amd)define("Parallax",["module"],e);else if("undefined"!=typeof exports)e(module);else{var i={exports:{}};e(i),t.Parallax=i.exports}}(this,function(t){"use strict";function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){var i;return i="string"==typeof t?(e||document).querySelectorAll(t):t,Array.prototype.slice.call(i)}function n(t){for(var e,i=arguments,n=1;n<i.length;++n)if(e=i[n])for(var r in e)t[r]=e[r];return t}function r(t){return"undefined"==typeof t}function s(t,e){return e?t.dataset[e]||t.getAttribute("data-"+e):t.dataset||Array.prototype.slice.call(t.attributes).reduce(function(t,e){return/data-/.test(e.name)&&(t[e.name]=e.value),t},{})}function o(t,e,i){for(var n=["ms","o","Moz","webkit",""],r=n.length;r--;){var s=n[r],o=s?s+e[0].toUpperCase()+e.substr(1):e.toLowerCase()+e.substr(1);if(o in t)return t[o]=i,!0}return!1}var a,u=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),h=function(t){t=t||{};var e={},i=Array.prototype.slice,n=function(t,e){t.replace(/\S+/g,e)},r=function(e,i){Object.defineProperty(t,e,{value:i,enumerable:!1,writable:!1,configurable:!1})};return r("on",function(i,r){return"function"!=typeof r?t:(n(i,function(t,i){(e[t]=e[t]||[]).push(r),r.typed=i>0}),t)}),r("off",function(i,r){return"*"!=i||r?n(i,function(t){if(r)for(var i,n=e[t],s=0;i=n&&n[s];++s)i==r&&n.splice(s--,1);else delete e[t]}):e={},t}),r("one",function(e,i){function n(){t.off(e,n),i.apply(t,arguments)}return t.on(e,n)}),r("trigger",function(r){var s,o=i.call(arguments,1);return n(r,function(n){s=i.call(e[n]||[],0);for(var r,a=0;r=s[a];++a){if(r.busy)return;r.busy=1,r.apply(t,r.typed?[n].concat(o):o),s[a]!==r&&a--,r.busy=0}e["*"]&&"*"!=n&&t.trigger.apply(t,["*",n].concat(o))}),t}),t},c=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame||function(t){setTimeout(t,1e3/60)},l=20,f=function(){function t(){e(this,t),h(this),this.resizeTimer=null,this.tick=!1,this.bind()}return u(t,[{key:"bind",value:function(){var t=this;return window.addEventListener("scroll",function(){return t.scroll()},!0),window.addEventListener("mousewheel",function(){return t.scroll()},!0),window.addEventListener("touchmove",function(){return t.scroll()},!0),window.addEventListener("resize",function(){return t.resize()},!0),window.addEventListener("orientationchange",function(){return t.resize()},!0),window.onload=function(){return t.scroll()},this}},{key:"scroll",value:function(){var t=this;return this.tick?this:(this.tick=!this.tick,c(function(){return t.update()}),this)}},{key:"update",value:function(){return this.trigger("scroll",this.scrollTop),this.tick=!this.tick,this}},{key:"resize",value:function(){var t=this;return this.resizeTimer&&clearTimeout(this.resizeTimer),this.resizeTimer=setTimeout(function(){return t.trigger("resize",t.size)},l),this}},{key:"scrollTop",get:function(){var t=(window.pageYOffset||document.scrollTop)-(document.clientTop||0);return window.isNaN(t)?0:t}},{key:"height",get:function(){return window.innerHeight}},{key:"width",get:function(){return window.innerWidth}},{key:"size",get:function(){return{width:this.width,height:this.height}}}]),t}(),d=function(t){return o(t.style,"transform","translate3d(0, 0, 0)"),/translate3d/g.test(t.style.cssText)}(document.createElement("div")),g=function(){function t(i,n){e(this,t),h(this),this.opts=n,this.img=i,this.wrapper=i.parentNode,this.isLoaded=!1}return u(t,[{key:"load",value:function(){var t=this;return this.img.width&&this.img.height&&this.img.complete?this.onImageLoaded():this.img.onload=function(){return t.onImageLoaded()},this}},{key:"onImageLoaded",value:function(){return this.isLoaded=!0,this.update(),this.trigger("loaded",this.img),this}},{key:"update",value:function(){var t=this.img.naturalWidth||this.img.width,e=this.img.naturalHeight||this.img.height,i=t/e,n=this.size;return n.width/i<=n.height?(this.img.height=n.height,this.img.width=n.height*i):(this.img.width=n.width,this.img.height=n.width/i),this.img.style.top=-~~((this.img.height-n.height)/2)+"px",this.img.style.left=-~~((this.img.width-n.width)/2)+"px",this}},{key:"draw",value:function(t){var e=this.size,i=(this.offset.top+e.height*this.opts.center+t.height/2-t.scrollTop)/t.height-1;return i*=this.img.height/e.height/2*this.opts.intensity,d?o(this.img.style,"transform","translate3d(0, "+-i+"%, 0)"):o(this.img.style,"transform","translate(0, "+-i+"%)"),this}},{key:"bounds",get:function(){return this.wrapper.getBoundingClientRect()}},{key:"offset",get:function(){return{top:this.wrapper.offsetTop,left:this.wrapper.offsetLeft}}},{key:"size",get:function(){var t=this.bounds;return{height:0|t.height,width:0|t.width}}}]),t}(),m=function(){function t(i){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return e(this,t),h(this),this.opts=n,this.selector=i,this.canvases=[],this.add(i),a||(a=new f),this}return u(t,[{key:"init",value:function(){return this.canvases.length?(this.imagesLoaded=0,this.bind()):console.warn('No images were found with the selector "'+this.selector+'"'),this}},{key:"bind",value:function(){var t=this;return this._onResize=function(){for(var e=arguments.length,i=Array(e),n=0;e>n;n++)i[n]=arguments[n];return t.resize.apply(t,i)},this._onScroll=function(){for(var e=arguments.length,i=Array(e),n=0;e>n;n++)i[n]=arguments[n];return t.scroll.apply(t,i)},a.on("resize",this._onResize),a.on("scroll",this._onScroll),this.canvases.forEach(function(e){e.one("loaded",function(){return t.onCanvasLoaded(e)}),e.load()}),this}},{key:"refresh",value:function(){return this.onResize(a.size).onScroll(a.scrollTop),this}},{key:"onCanvasLoaded",value:function(t){return this.trigger("image:loaded",t.img,t),this.imagesLoaded++,t.draw(a),this.imagesLoaded==this.canvases.length&&this.trigger("images:loaded"),this}},{key:"scroll",value:function(t){for(var e=this.canvases.length,i=this.opts.offsetYBounds,n=a.scrollTop;e--;){var r=this.canvases[e],s=r.size.height,o=r.offset,u=o.top+s-n;r.isLoaded&&u+i>0&&u-i<n+a.height&&(r.draw(a),this.trigger("draw",r.img))}return this.trigger("update",n),this}},{key:"add",value:function(t){return this.canvases=this.canvases.concat(this.createCanvases(i(t))),this}},{key:"remove",value:function(t){var e=this;return i(t).forEach(function(t){for(var i=e.canvases.length;i--;)if(t==e.canvases[i].img){e.canvases.splice(i,1);break}}),this}},{key:"destroy",value:function(){return this.off("*"),this.canvases=[],a.off("resize",this._onResize).off("scroll",this._onScroll),this}},{key:"resize",value:function(t){for(var e=this.canvases.length;e--;){var i=this.canvases[e];if(!i.isLoaded)return;i.update().draw(a)}return this.trigger("resize"),this}},{key:"createCanvases",value:function(t){var e=this;return t.map(function(t){var i=s(t);return new g(t,{intensity:r(i.intensity)?e.opts.intensity:+i.intensity,center:r(i.center)?e.opts.center:+i.center})})}},{key:"opts",set:function(t){this._defaults={offsetYBounds:50,intensity:30,center:.5},n(this._defaults,t)},get:function(){return this._defaults}}]),t}();t.exports=m});
// use here your library name
module.exports = require('./dist/Parallax');
module.exports = require('./dist/Parallax')
{
"name": "scroll-parallax",
"version": "1.0.2",
"version": "1.0.3",
"description": "ES6/ES2015 unobstrusive modern HW accelerated scrollable images parallax",

@@ -16,3 +16,3 @@ "main": "index.js",

"default": "node make",
"prepublish": "npm run default"
"prepublish": "npm run default && npm run minify"
},

@@ -19,0 +19,0 @@ "repository": {

@@ -153,2 +153,3 @@ import { $, $$, extend, isUndefined, elementData } from './helpers/helpers'

this.off('*')
this.canvases = []
stage.off('resize', this._onResize).off('scroll', this._onScroll)

@@ -155,0 +156,0 @@ return this

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