Socket
Socket
Sign inDemoInstall

scroll-parallax

Package Overview
Dependencies
1
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.1 to 2.0.2

3

CHANGELOG.md
## Changelog
### 2.0.2
* fixed: missing minified version of the script
### 2.0.1

@@ -4,0 +7,0 @@ * added: the `will-change` attribute hoping to gain better performances

2

dist/Parallax.min.js

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

dist,Parallax.js;
!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=void 0,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 void 0===t}function s(t){return t.replace(/-(\w)/g,function(t,e){return e.toUpperCase()})}function o(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[s(e.name)]=e.value),t},{})}function a(t,e){for(var i=["ms","o","Moz","webkit"],n=i.length;n--;){var r=i[n],s=r?r+e[0].toUpperCase()+e.substr(1):e.toLowerCase()+e.substr(1);if(s in t)return s}return""}var h=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}}(),u=function(t){t=t||{};var e={},i=Array.prototype.slice;return Object.defineProperties(t,{on:{value:function(i,n){return"function"==typeof n&&(e[i]=e[i]||[]).push(n),t},enumerable:!1,writable:!1,configurable:!1},off:{value:function(i,n){if("*"!=i||n)if(n)for(var r,s=e[i],o=0;r=s&&s[o];++o)r==n&&s.splice(o--,1);else delete e[i];else e={};return t},enumerable:!1,writable:!1,configurable:!1},one:{value:function(e,i){function n(){t.off(e,n),i.apply(t,arguments)}return t.on(e,n)},enumerable:!1,writable:!1,configurable:!1},trigger:{value:function(n){var r,s,o,a=arguments.length-1,h=new Array(a);for(o=0;o<a;o++)h[o]=arguments[o+1];for(r=i.call(e[n]||[],0),o=0;s=r[o];++o)s.apply(t,h);return e["*"]&&"*"!=n&&t.trigger.apply(t,["*",n].concat(h)),t},enumerable:!1,writable:!1,configurable:!1}}),t},c=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame||function(t){setTimeout(t,1e3/60)},l=function(){function t(){e(this,t),u(this),this.resizeTimer=null,this.tick=!1,this.bind()}return h(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)},20),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}(),f=a(document.createElement("div").style,"transform"),d=function(t){return t.style[f]="matrix(1, 0, 0, 1, 0, 0)",/matrix/g.test(t.style.cssText)}(document.createElement("div")),g=function(){function t(i,n){e(this,t),u(this),this.opts=n,this.img=i,this.wrapper=i.parentNode,this.isLoaded=!1}return h(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.img.style.willChange="transform",this.trigger("loaded",this.img),this}},{key:"update",value:function(){var t=(this.img.naturalWidth||this.img.width)/(this.img.naturalHeight||this.img.height),e=this.size,i=void 0,n=void 0,r=void 0,s=void 0;return e.width/t<=e.height?(n=e.height*t,i=e.height):(n=e.width,i=e.width/t),i<=e.height+e.height*this.opts.safeHeight&&(n+=n*this.opts.safeHeight,i+=i*this.opts.safeHeight),r=-~~((i-e.height)/2),s=-~~((n-e.width)/2),this.img.width=n,this.img.height=i,this.img.style.top=r+"px",this.img.style.left=s+"px",this}},{key:"draw",value:function(t){var e=t.scrollTop,i=(t.width,t.height),n=this.size,r=~~(((this.offset.top+n.height*this.opts.center+i/2-e)/i-1)*(this.img.height/n.height/2*this.opts.intensity)*10);return this.img.style[f]=d?"matrix(1,0,0,1, 0, "+-r+")":"translate(0, "+-r+"px)",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}(),v=void 0,p=function(){function t(i){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e(this,t),u(this),this.opts=n,this.selector=i,this.canvases=[],this.add(i),v||(v=new l),this}return h(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;n<e;n++)i[n]=arguments[n];return t.resize.apply(t,i)},this._onScroll=function(){for(var e=arguments.length,i=Array(e),n=0;n<e;n++)i[n]=arguments[n];return t.scroll.apply(t,i)},v.on("resize",this._onResize),v.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(v.size).onScroll(v.scrollTop),this}},{key:"onCanvasLoaded",value:function(t){return this.trigger("image:loaded",t.img,t),this.imagesLoaded++,t.draw(v),this.imagesLoaded==this.canvases.length&&this.trigger("images:loaded"),this}},{key:"scroll",value:function(t){for(var e=this.opts.offsetYBounds,i=v,n=i.height,r=i.width,s=this.canvases.length;s--;){var o=this.canvases[s],a=o.size.height,h=o.offset;o.isLoaded&&t+v.height+e>h.top&&h.top+a>t-e&&(o.draw({height:n,scrollTop:t,width:r}),this.trigger("draw",o.img))}return this.trigger("update",t),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=[],v.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(v)}return this.trigger("resize"),this}},{key:"createCanvases",value:function(t){var e=this;return t.map(function(t){var i=o(t);return new g(t,{intensity:r(i.intensity)?e.opts.intensity:+i.intensity,center:r(i.center)?e.opts.center:+i.center,safeHeight:r(i.safeHeight)?e.opts.safeHeight:+i.safeHeight})})}},{key:"opts",set:function(t){this._defaults={offsetYBounds:50,intensity:30,center:.5,safeHeight:.15},n(this._defaults,t)},get:function(){return this._defaults}}]),t}();t.exports=p});
{
"name": "scroll-parallax",
"version": "2.0.1",
"version": "2.0.2",
"description": "ES6/ES2015 unobstrusive modern HW accelerated scrollable images parallax",

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

@@ -14,3 +14,3 @@ var utils = require('./_utils'),

outputPath = `${options.base}${global.library}.min.js`,
output = uglify.minify(sourcePath)
output = uglify.minify(fs.readFileSync(sourcePath, 'utf8'))

@@ -17,0 +17,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