scrollreveal
Advanced tools
Comparing version 4.0.0-beta.4 to 4.0.0-beta.5
@@ -1078,3 +1078,3 @@ (function (global, factory) { | ||
function triggerReveal (element, isDelayed) { | ||
function triggerReveal (element, delayed) { | ||
var styles = [ | ||
@@ -1084,3 +1084,3 @@ element.styles.inline, | ||
element.styles.transform.generated.final ]; | ||
isDelayed | ||
delayed | ||
? styles.push(element.styles.transition.generated.delayed) | ||
@@ -1090,3 +1090,3 @@ : styles.push(element.styles.transition.generated.instant); | ||
element.node.setAttribute('style', styles.filter(function (i) { return i !== ''; }).join(' ')); | ||
registerCallbacks.call(this, element, isDelayed); | ||
registerCallbacks.call(this, element, delayed); | ||
} | ||
@@ -1150,3 +1150,3 @@ | ||
var element = this$1.store.elements[id]; | ||
if (element.visible) { | ||
if (element && element.visible) { | ||
min = Math.min(min, element.sequence.index); | ||
@@ -1241,3 +1241,3 @@ max = Math.max(max, element.sequence.index); | ||
var version = "4.0.0-beta.4"; | ||
var version = "4.0.0-beta.5"; | ||
@@ -1244,0 +1244,0 @@ function ScrollReveal (options) { |
@@ -1,1 +0,1 @@ | ||
var ScrollReveal=function(){"use strict";function e(i){for(var r=[],o=arguments.length-1;o-- >0;)r[o]=arguments[o+1];if(t(i))return n(r,function(r){n(r,function(n,r){t(n)?(i[r]&&t(i[r])||(i[r]={}),e(i[r],n)):i[r]=n})}),i;throw new TypeError("Expected an object literal.")}function t(e){return null!==e&&"object"==typeof e&&(e.constructor===Object||"[object Object]"===Object.prototype.toString.call(e))}function n(e,n){if(t(e))for(var i=Object.keys(e),r=0;r<i.length;r++)n(e[i[r]],i[r],e);else{if(!Array.isArray(e))throw new TypeError("Expected either an array or object literal.");for(var o=0;o<e.length;o++)n(e[o],o,e)}}function i(e){return void 0===e&&(e=navigator.userAgent),/Android|iPhone|iPad|iPod/i.test(e)}function r(e){return"object"==typeof window.Node?e instanceof window.Node:null!==e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName}function o(e){var t=Object.prototype.toString.call(e),n=/^\[object (HTMLCollection|NodeList|Object)\]$/;return"object"==typeof window.NodeList?e instanceof window.NodeList:"object"==typeof e&&"number"==typeof e.length&&n.test(t)&&(0===e.length||r(e[0]))}function s(){var e=document.documentElement.style;return"transform"in e||"WebkitTransform"in e}function a(){var e=document.documentElement.style;return"transition"in e||"WebkitTransition"in e}function l(e){var t=this.store.containers[e.containerId],n=e.config.viewFactor,i=e.config.viewOffset,r={top:e.geometry.bounds.top+e.geometry.height*n,right:e.geometry.bounds.right-e.geometry.width*n,bottom:e.geometry.bounds.bottom-e.geometry.height*n,left:e.geometry.bounds.left+e.geometry.width*n},o={top:t.geometry.bounds.top+t.scroll.top+i.top,right:t.geometry.bounds.right+t.scroll.left-i.right,bottom:t.geometry.bounds.bottom+t.scroll.top-i.bottom,left:t.geometry.bounds.left+t.scroll.left+i.left};return r.top<o.bottom&&r.right>o.left&&r.bottom>o.top&&r.left<o.right||"fixed"===e.styles.position}function c(e,t){var n=t?e.node.clientHeight:e.node.offsetHeight,i=t?e.node.clientWidth:e.node.offsetWidth,r=0,o=0,s=e.node;do{isNaN(s.offsetTop)||(r+=s.offsetTop),isNaN(s.offsetLeft)||(o+=s.offsetLeft),s=s.offsetParent}while(s);return{bounds:{top:r,right:o+i,bottom:r+n,left:o},height:n,width:i}}function u(e,t){void 0===t&&(t=document);var n=null;if("string"==typeof e)try{n=t.querySelector(e)}catch(e){}return r(e)?e:n}function d(e,t){if(void 0===t&&(t=document),r(e))return[e];if(o(e))return Array.prototype.slice.call(e);if("string"==typeof e)try{var n=t.querySelectorAll(e),i=Array.prototype.slice.call(n);if(i.length)return i}catch(e){}return[]}function f(e){return e.node===document.documentElement?{top:window.pageYOffset,left:window.pageXOffset}:{top:e.node.scrollTop,left:e.node.scrollLeft}}function p(){var e=this,t={active:[],stale:[]},i={active:[],stale:[]},r={active:[],stale:[]};n(d("[data-sr-id]"),function(e){var n=parseInt(e.getAttribute("data-sr-id"));t.active.push(n)}),n(this.store.elements,function(e){-1===t.active.indexOf(e.id)&&t.stale.push(e.id)}),n(t.stale,function(t){return delete e.store.elements[t]}),n(this.store.elements,function(e){-1===i.active.indexOf(e.containerId)&&i.active.push(e.containerId),e.hasOwnProperty("sequence")&&-1===r.active.indexOf(e.sequence.id)&&r.active.push(e.sequence.id)}),n(this.store.containers,function(e){-1===i.active.indexOf(e.id)&&i.stale.push(e.id)}),n(i.stale,function(t){e.store.containers[t].node.removeEventListener("scroll",e.delegate),e.store.containers[t].node.removeEventListener("resize",e.delegate),delete e.store.containers[t]}),n(this.store.sequences,function(e){-1===r.active.indexOf(e.id)&&r.stale.push(e.id)}),n(r.stale,function(t){return delete e.store.sequences[t]})}function h(e){var t,i=this;n(d(e),function(e){var n=e.getAttribute("data-sr-id");null!==n&&(t=!0,e.setAttribute("style",i.store.elements[n].styles.inline),e.removeAttribute("data-sr-id"),delete i.store.elements[n])}),t&&p.call(this)}function y(){var e=this;n(this.store.elements,function(e){e.node.setAttribute("style",e.styles.inline),e.node.removeAttribute("data-sr-id")}),n(this.store.containers,function(t){t.node===document.documentElement?(window.removeEventListener("scroll",e.delegate),window.removeEventListener("resize",e.delegate)):(t.node.removeEventListener("scroll",e.delegate),t.node.removeEventListener("resize",e.delegate))}),this.store={containers:{},elements:{},history:[],sequences:{}}}function m(e){if(e.constructor!==Array)throw new TypeError("Expected array.");if(16===e.length)return e;if(6===e.length){var t=g();return t[0]=e[0],t[1]=e[1],t[4]=e[2],t[5]=e[3],t[12]=e[4],t[13]=e[5],t}throw new RangeError("Expected array with either 6 or 16 values.")}function g(){for(var e=[],t=0;t<16;t++)t%5==0?e.push(1):e.push(0);return e}function v(e,t){for(var n=m(e),i=m(t),r=[],o=0;o<4;o++)for(var s=[n[o],n[o+4],n[o+8],n[o+12]],a=0;a<4;a++){var l=4*a,c=[i[l],i[l+1],i[l+2],i[l+3]],u=s[0]*c[0]+s[1]*c[1]+s[2]*c[2]+s[3]*c[3];r[o+l]=u}return r}function b(e){if("string"==typeof e){var t=e.match(/matrix(3d)?\(([^)]+)\)/);if(t){return m(t[2].split(", ").map(function(e){return parseFloat(e)}))}}return g()}function w(e){var t=Math.PI/180*e,n=g();return n[5]=n[10]=Math.cos(t),n[6]=n[9]=Math.sin(t),n[9]*=-1,n}function x(e){var t=Math.PI/180*e,n=g();return n[0]=n[10]=Math.cos(t),n[2]=n[8]=Math.sin(t),n[2]*=-1,n}function E(e){var t=Math.PI/180*e,n=g();return n[0]=n[5]=Math.cos(t),n[1]=n[4]=Math.sin(t),n[4]*=-1,n}function k(e,t){var n=g();return n[0]=e,n[5]=t||e,n}function T(e){var t=g();return t[12]=e,t}function j(e){var t=g();return t[13]=e,t}function A(e){var t=window.getComputedStyle(e.node),n=t.position,i=e.config,r=/.+[^;]/g,o=e.node.getAttribute("style")||"",s=r.exec(o),a=s?s[0]+";":"";-1===a.indexOf("visibility: visible")&&(a+=a.length?" ":"",a+="visibility: visible;");var l=parseFloat(t.opacity),c=isNaN(parseFloat(i.opacity))?parseFloat(t.opacity):parseFloat(i.opacity),u={computed:l!==c?"opacity: "+l+";":"",generated:l!==c?"opacity: "+c+";":""},d=[];if(parseFloat(i.distance)){var f="top"===i.origin||"bottom"===i.origin?"Y":"X",p=i.distance;"top"!==i.origin&&"left"!==i.origin||(p=/^-/.test(p)?p.substr(1):"-"+p);var h=p.match(/(^-?\d+\.?\d?)|(em$|px$|\%$)/g),y=h[0];switch(h[1]){case"em":p=parseInt(t.fontSize)*y;break;case"px":p=y;break;case"%":p="Y"===f?e.node.getBoundingClientRect().height*y/100:e.node.getBoundingClientRect().width*y/100;break;default:throw new RangeError("Unrecognized or missing distance unit.")}"Y"===f?d.push(j(p)):d.push(T(p))}i.rotate.x&&d.push(w(i.rotate.x)),i.rotate.y&&d.push(x(i.rotate.y)),i.rotate.z&&d.push(E(i.rotate.z)),1!==i.scale&&d.push(k(i.scale));var m={};if(d.length){m.property=$("transform"),m.computed={raw:t[m.property],matrix:b(t[m.property])},d.unshift(m.computed.matrix);var g=d.reduce(v);m.generated={initial:m.property+": matrix3d("+g.join(", ")+");",final:m.property+": matrix3d("+m.computed.matrix.join(", ")+");"}}else m.generated={initial:"",final:""};var A={};if(u.generated||m.generated.initial){A.property=$("transition"),A.computed=t[A.property],A.fragments=[];var q=i.delay,O=i.duration,L=i.easing;u.generated&&A.fragments.push({delayed:"opacity "+O/1e3+"s "+L+" "+q/1e3+"s",instant:"opacity "+O/1e3+"s "+L+" 0s"}),m.generated.initial&&A.fragments.push({delayed:m.property+" "+O/1e3+"s "+L+" "+q/1e3+"s",instant:m.property+" "+O/1e3+"s "+L+" 0s"}),A.computed&&!A.computed.match(/all 0s/)&&A.fragments.unshift({delayed:A.computed,instant:A.computed});var I=A.fragments.reduce(function(e,t,n){return e.delayed+=0===n?t.delayed:", "+t.delayed,e.instant+=0===n?t.instant:", "+t.instant,e},{delayed:"",instant:""});A.generated={delayed:A.property+": "+I.delayed+";",instant:A.property+": "+I.instant+";"}}else A.generated={delayed:"",instant:""};return{inline:a,opacity:u,position:n,transform:m,transition:A}}function q(){var e=this;p.call(this),n(this.store.elements,function(e){var t=[e.styles.inline];e.visible?(t.push(e.styles.opacity.computed),t.push(e.styles.transform.generated.final)):(t.push(e.styles.opacity.generated),t.push(e.styles.transform.generated.initial)),e.node.setAttribute("style",t.filter(function(e){return""!==e}).join(" "))}),n(this.store.containers,function(t){t.node===document.documentElement?(window.addEventListener("scroll",e.delegate),window.addEventListener("resize",e.delegate)):(t.node.addEventListener("scroll",e.delegate),t.node.addEventListener("resize",e.delegate))}),this.delegate(),this.initTimeout=null}function O(t,r,o,s){var a=this;"number"==typeof r?(o=Math.abs(parseInt(r)),r={}):(o=Math.abs(parseInt(o)),r=r||{});var l=e({},this.defaults,r),c=this.store.containers,f=u(l.container),p=d(t,f);if(p.length&&(l.mobile||!i())&&(l.desktop||i())){var h;if(o){if(!(o>=16))return;var y=Y();h={elementIds:[],nose:{blocked:!1,index:null,pointer:null},tail:{blocked:!1,index:null,pointer:null},id:y,interval:Math.abs(o)}}var m;n(c,function(e){m||e.node!==f||(m=e.id)}),isNaN(m)&&(m=Y());try{n(p.map(function(t){var n={},i=t.getAttribute("data-sr-id");return i?(e(n,a.store.elements[i]),n.node.setAttribute("style",n.styles.inline)):(n.id=Y(),n.node=t,n.seen=!1,n.revealed=!1,n.visible=!1),n.config=l,n.containerId=m,n.styles=A(n),h&&(n.sequence={id:h.id,index:h.elementIds.length},h.elementIds.push(n.id)),n}),function(e){a.store.elements[e.id]=e,e.node.setAttribute("data-sr-id",e.id)})}catch(e){return}c[m]=c[m]||{id:m,node:f},h&&(this.store.sequences[h.id]=h),s||(this.store.history.push({target:t,options:r,interval:o}),this.initTimeout&&window.clearTimeout(this.initTimeout),this.initTimeout=window.setTimeout(q.bind(this),0))}}function L(){var e=this;n(this.store.history,function(t){O.call(e,t.target,t.options,t.interval,!0)}),q.call(this)}function I(e,t){var n=this.store.sequences[e.sequence.id],i="always"===e.config.useDelay||"onload"===e.config.useDelay&&this.pristine||"once"===e.config.useDelay&&!e.seen;if(e.visible=l.call(this,e),t){if(e.sequence.index===n.nose.pointer-1&&n.nose.pointer>n.nose.index)n.nose.pointer--,P.call(this,n);else{if(!(e.sequence.index===n.tail.pointer+1&&n.tail.pointer<n.tail.index))return;n.tail.pointer++,F.call(this,n)}return M.call(this,e,i)}if(e.visible&&!e.revealed){if(n)if(z.call(this,n),null===n.nose.pointer&&null===n.tail.pointer)n.nose.pointer=n.tail.pointer=e.sequence.index,P.call(this,n),F.call(this,n);else if(e.sequence.index!==n.nose.pointer-1||n.nose.blocked){if(e.sequence.index!==n.tail.pointer+1||n.tail.blocked)return;n.tail.pointer++,F.call(this,n)}else n.nose.pointer--,P.call(this,n);return e.seen=!0,M.call(this,e,i)}if(!e.visible&&e.revealed&&e.config.reset)return n&&(z.call(this,n),n.nose.index!==1/0&&n.tail.index!==-1/0&&(n.nose.pointer=Math.max(n.nose.pointer,n.nose.index),n.tail.pointer=Math.min(n.tail.pointer,n.tail.index))),R.call(this,e)}function M(e,t){var n=[e.styles.inline,e.styles.opacity.computed,e.styles.transform.generated.final];t?n.push(e.styles.transition.generated.delayed):n.push(e.styles.transition.generated.instant),e.revealed=!0,e.node.setAttribute("style",n.filter(function(e){return""!==e}).join(" ")),N.call(this,e,t)}function R(e){var t=[e.styles.inline,e.styles.opacity.generated,e.styles.transform.generated.initial,e.styles.transition.generated.instant];e.revealed=!1,e.node.setAttribute("style",t.filter(function(e){return""!==e}).join(" ")),N.call(this,e)}function N(e,t){var n=this,i=t?e.config.duration+e.config.delay:e.config.duration,r=e.revealed?e.config.beforeReveal:e.config.beforeReset,o=e.revealed?e.config.afterReveal:e.config.afterReset,s=0;e.callbackTimer&&(s=Date.now()-e.callbackTimer.start,window.clearTimeout(e.callbackTimer.clock)),r(e.node),e.callbackTimer={start:Date.now(),clock:window.setTimeout(function(){o(e.node),e.callbackTimer=null,e.revealed&&!e.config.reset&&h.call(n,e.node)},i-s)}}function z(e){var t=this,i=1/0,r=-1/0;n(e.elementIds,function(e){var n=t.store.elements[e];n.visible&&(i=Math.min(i,n.sequence.index),r=Math.max(r,n.sequence.index))}),e.nose.index=i,e.tail.index=r}function P(e){var t=this,n=e.elementIds[e.nose.pointer-1],i=this.store.elements[n];i&&(e.nose.blocked=!0,window.setTimeout(function(){e.nose.blocked=!1,I.call(t,i,!0)},e.interval))}function F(e){var t=this,n=e.elementIds[e.tail.pointer+1],i=this.store.elements[n];i&&(e.tail.blocked=!0,window.setTimeout(function(){e.tail.blocked=!1,I.call(t,i,!0)},e.interval))}function S(e){var t=this;void 0===e&&(e={}),B(function(){var i=t.store.containers,r=t.store.elements;switch(e.type){case"scroll":n(i,function(e){return e.scroll=f.call(t,e)}),n(r,function(e){return I.call(t,e)});break;case"resize":default:n(i,function(e){e.geometry=c.call(t,e,!0),e.scroll=f.call(t,e)}),n(r,function(e){e.geometry=c.call(t,e),I.call(t,e)})}t.pristine=!1})}function D(t){if(void 0===t&&(t={}),void 0===this||Object.getPrototypeOf(this)!==D.prototype)return new D(t);if(!D.isSupported())return W;try{Object.defineProperty(this,"defaults",{get:function(){var n={};return e(n,C,t),function(){return n}}()})}catch(e){return W}if(!u(this.defaults.container))return W;this.defaults.mobile!==i()&&this.defaults.desktop!==!i()||document.documentElement.classList.add("sr"),this.store={containers:{},elements:{},history:[],sequences:{}},this.pristine=!0,this.delegate=S.bind(this),Object.defineProperty(this,"version",{get:function(){return U}}),Object.defineProperty(this,"noop",{get:function(){return!1}})}var C={origin:"bottom",distance:"0",duration:600,delay:0,rotate:{x:0,y:0,z:0},opacity:0,scale:1,easing:"cubic-bezier(0.6, 0.2, 0.1, 1)",container:document.documentElement,desktop:!0,mobile:!0,reset:!1,useDelay:"always",viewFactor:0,viewOffset:{top:0,right:0,bottom:0,left:0},beforeReveal:function(){},beforeReset:function(){},afterReveal:function(){},afterReset:function(){}},W={clean:function(){},destroy:function(){},reveal:function(){},sync:function(){},get noop(){return!0}},Y=function(){var e=0;return function(){return e++}}(),$=function(){function e(e,i){if(void 0===i&&(i=n),e&&"string"==typeof e){if(t[e])return t[e];if("string"==typeof i[e])return t[e]=e;if("string"==typeof i["-webkit-"+e])return t[e]="-webkit-"+e;throw new RangeError('Unable to find "'+e+'" style property.')}throw new TypeError("Expected a string.")}var t={},n=document.documentElement.style;return e.clearCache=function(){return t={}},e}(),H=function(){var e=Date.now();return function(t){var n=Date.now();n-e>16?(e=n,t(n)):setTimeout(function(){return H(t)},0)}}(),B=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||H,U="4.0.0-beta.4";return D.isSupported=function(){return s()&&a()},D.prototype.clean=h,D.prototype.destroy=y,D.prototype.reveal=O,D.prototype.sync=L,D}(); | ||
var ScrollReveal=function(){"use strict";function e(i){for(var r=[],o=arguments.length-1;o-- >0;)r[o]=arguments[o+1];if(t(i))return n(r,function(r){n(r,function(n,r){t(n)?(i[r]&&t(i[r])||(i[r]={}),e(i[r],n)):i[r]=n})}),i;throw new TypeError("Expected an object literal.")}function t(e){return null!==e&&"object"==typeof e&&(e.constructor===Object||"[object Object]"===Object.prototype.toString.call(e))}function n(e,n){if(t(e))for(var i=Object.keys(e),r=0;r<i.length;r++)n(e[i[r]],i[r],e);else{if(!Array.isArray(e))throw new TypeError("Expected either an array or object literal.");for(var o=0;o<e.length;o++)n(e[o],o,e)}}function i(e){return void 0===e&&(e=navigator.userAgent),/Android|iPhone|iPad|iPod/i.test(e)}function r(e){return"object"==typeof window.Node?e instanceof window.Node:null!==e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName}function o(e){var t=Object.prototype.toString.call(e),n=/^\[object (HTMLCollection|NodeList|Object)\]$/;return"object"==typeof window.NodeList?e instanceof window.NodeList:"object"==typeof e&&"number"==typeof e.length&&n.test(t)&&(0===e.length||r(e[0]))}function s(){var e=document.documentElement.style;return"transform"in e||"WebkitTransform"in e}function a(){var e=document.documentElement.style;return"transition"in e||"WebkitTransition"in e}function l(e){var t=this.store.containers[e.containerId],n=e.config.viewFactor,i=e.config.viewOffset,r={top:e.geometry.bounds.top+e.geometry.height*n,right:e.geometry.bounds.right-e.geometry.width*n,bottom:e.geometry.bounds.bottom-e.geometry.height*n,left:e.geometry.bounds.left+e.geometry.width*n},o={top:t.geometry.bounds.top+t.scroll.top+i.top,right:t.geometry.bounds.right+t.scroll.left-i.right,bottom:t.geometry.bounds.bottom+t.scroll.top-i.bottom,left:t.geometry.bounds.left+t.scroll.left+i.left};return r.top<o.bottom&&r.right>o.left&&r.bottom>o.top&&r.left<o.right||"fixed"===e.styles.position}function c(e,t){var n=t?e.node.clientHeight:e.node.offsetHeight,i=t?e.node.clientWidth:e.node.offsetWidth,r=0,o=0,s=e.node;do{isNaN(s.offsetTop)||(r+=s.offsetTop),isNaN(s.offsetLeft)||(o+=s.offsetLeft),s=s.offsetParent}while(s);return{bounds:{top:r,right:o+i,bottom:r+n,left:o},height:n,width:i}}function u(e,t){void 0===t&&(t=document);var n=null;if("string"==typeof e)try{n=t.querySelector(e)}catch(e){}return r(e)?e:n}function d(e,t){if(void 0===t&&(t=document),r(e))return[e];if(o(e))return Array.prototype.slice.call(e);if("string"==typeof e)try{var n=t.querySelectorAll(e),i=Array.prototype.slice.call(n);if(i.length)return i}catch(e){}return[]}function f(e){return e.node===document.documentElement?{top:window.pageYOffset,left:window.pageXOffset}:{top:e.node.scrollTop,left:e.node.scrollLeft}}function p(){var e=this,t={active:[],stale:[]},i={active:[],stale:[]},r={active:[],stale:[]};n(d("[data-sr-id]"),function(e){var n=parseInt(e.getAttribute("data-sr-id"));t.active.push(n)}),n(this.store.elements,function(e){-1===t.active.indexOf(e.id)&&t.stale.push(e.id)}),n(t.stale,function(t){return delete e.store.elements[t]}),n(this.store.elements,function(e){-1===i.active.indexOf(e.containerId)&&i.active.push(e.containerId),e.hasOwnProperty("sequence")&&-1===r.active.indexOf(e.sequence.id)&&r.active.push(e.sequence.id)}),n(this.store.containers,function(e){-1===i.active.indexOf(e.id)&&i.stale.push(e.id)}),n(i.stale,function(t){e.store.containers[t].node.removeEventListener("scroll",e.delegate),e.store.containers[t].node.removeEventListener("resize",e.delegate),delete e.store.containers[t]}),n(this.store.sequences,function(e){-1===r.active.indexOf(e.id)&&r.stale.push(e.id)}),n(r.stale,function(t){return delete e.store.sequences[t]})}function h(e){var t,i=this;n(d(e),function(e){var n=e.getAttribute("data-sr-id");null!==n&&(t=!0,e.setAttribute("style",i.store.elements[n].styles.inline),e.removeAttribute("data-sr-id"),delete i.store.elements[n])}),t&&p.call(this)}function y(){var e=this;n(this.store.elements,function(e){e.node.setAttribute("style",e.styles.inline),e.node.removeAttribute("data-sr-id")}),n(this.store.containers,function(t){t.node===document.documentElement?(window.removeEventListener("scroll",e.delegate),window.removeEventListener("resize",e.delegate)):(t.node.removeEventListener("scroll",e.delegate),t.node.removeEventListener("resize",e.delegate))}),this.store={containers:{},elements:{},history:[],sequences:{}}}function m(e){if(e.constructor!==Array)throw new TypeError("Expected array.");if(16===e.length)return e;if(6===e.length){var t=g();return t[0]=e[0],t[1]=e[1],t[4]=e[2],t[5]=e[3],t[12]=e[4],t[13]=e[5],t}throw new RangeError("Expected array with either 6 or 16 values.")}function g(){for(var e=[],t=0;t<16;t++)t%5==0?e.push(1):e.push(0);return e}function v(e,t){for(var n=m(e),i=m(t),r=[],o=0;o<4;o++)for(var s=[n[o],n[o+4],n[o+8],n[o+12]],a=0;a<4;a++){var l=4*a,c=[i[l],i[l+1],i[l+2],i[l+3]],u=s[0]*c[0]+s[1]*c[1]+s[2]*c[2]+s[3]*c[3];r[o+l]=u}return r}function b(e){if("string"==typeof e){var t=e.match(/matrix(3d)?\(([^)]+)\)/);if(t){return m(t[2].split(", ").map(function(e){return parseFloat(e)}))}}return g()}function w(e){var t=Math.PI/180*e,n=g();return n[5]=n[10]=Math.cos(t),n[6]=n[9]=Math.sin(t),n[9]*=-1,n}function x(e){var t=Math.PI/180*e,n=g();return n[0]=n[10]=Math.cos(t),n[2]=n[8]=Math.sin(t),n[2]*=-1,n}function E(e){var t=Math.PI/180*e,n=g();return n[0]=n[5]=Math.cos(t),n[1]=n[4]=Math.sin(t),n[4]*=-1,n}function k(e,t){var n=g();return n[0]=e,n[5]=t||e,n}function T(e){var t=g();return t[12]=e,t}function j(e){var t=g();return t[13]=e,t}function A(e){var t=window.getComputedStyle(e.node),n=t.position,i=e.config,r=/.+[^;]/g,o=e.node.getAttribute("style")||"",s=r.exec(o),a=s?s[0]+";":"";-1===a.indexOf("visibility: visible")&&(a+=a.length?" ":"",a+="visibility: visible;");var l=parseFloat(t.opacity),c=isNaN(parseFloat(i.opacity))?parseFloat(t.opacity):parseFloat(i.opacity),u={computed:l!==c?"opacity: "+l+";":"",generated:l!==c?"opacity: "+c+";":""},d=[];if(parseFloat(i.distance)){var f="top"===i.origin||"bottom"===i.origin?"Y":"X",p=i.distance;"top"!==i.origin&&"left"!==i.origin||(p=/^-/.test(p)?p.substr(1):"-"+p);var h=p.match(/(^-?\d+\.?\d?)|(em$|px$|\%$)/g),y=h[0];switch(h[1]){case"em":p=parseInt(t.fontSize)*y;break;case"px":p=y;break;case"%":p="Y"===f?e.node.getBoundingClientRect().height*y/100:e.node.getBoundingClientRect().width*y/100;break;default:throw new RangeError("Unrecognized or missing distance unit.")}"Y"===f?d.push(j(p)):d.push(T(p))}i.rotate.x&&d.push(w(i.rotate.x)),i.rotate.y&&d.push(x(i.rotate.y)),i.rotate.z&&d.push(E(i.rotate.z)),1!==i.scale&&d.push(k(i.scale));var m={};if(d.length){m.property=$("transform"),m.computed={raw:t[m.property],matrix:b(t[m.property])},d.unshift(m.computed.matrix);var g=d.reduce(v);m.generated={initial:m.property+": matrix3d("+g.join(", ")+");",final:m.property+": matrix3d("+m.computed.matrix.join(", ")+");"}}else m.generated={initial:"",final:""};var A={};if(u.generated||m.generated.initial){A.property=$("transition"),A.computed=t[A.property],A.fragments=[];var q=i.delay,O=i.duration,L=i.easing;u.generated&&A.fragments.push({delayed:"opacity "+O/1e3+"s "+L+" "+q/1e3+"s",instant:"opacity "+O/1e3+"s "+L+" 0s"}),m.generated.initial&&A.fragments.push({delayed:m.property+" "+O/1e3+"s "+L+" "+q/1e3+"s",instant:m.property+" "+O/1e3+"s "+L+" 0s"}),A.computed&&!A.computed.match(/all 0s/)&&A.fragments.unshift({delayed:A.computed,instant:A.computed});var I=A.fragments.reduce(function(e,t,n){return e.delayed+=0===n?t.delayed:", "+t.delayed,e.instant+=0===n?t.instant:", "+t.instant,e},{delayed:"",instant:""});A.generated={delayed:A.property+": "+I.delayed+";",instant:A.property+": "+I.instant+";"}}else A.generated={delayed:"",instant:""};return{inline:a,opacity:u,position:n,transform:m,transition:A}}function q(){var e=this;p.call(this),n(this.store.elements,function(e){var t=[e.styles.inline];e.visible?(t.push(e.styles.opacity.computed),t.push(e.styles.transform.generated.final)):(t.push(e.styles.opacity.generated),t.push(e.styles.transform.generated.initial)),e.node.setAttribute("style",t.filter(function(e){return""!==e}).join(" "))}),n(this.store.containers,function(t){t.node===document.documentElement?(window.addEventListener("scroll",e.delegate),window.addEventListener("resize",e.delegate)):(t.node.addEventListener("scroll",e.delegate),t.node.addEventListener("resize",e.delegate))}),this.delegate(),this.initTimeout=null}function O(t,r,o,s){var a=this;"number"==typeof r?(o=Math.abs(parseInt(r)),r={}):(o=Math.abs(parseInt(o)),r=r||{});var l=e({},this.defaults,r),c=this.store.containers,f=u(l.container),p=d(t,f);if(p.length&&(l.mobile||!i())&&(l.desktop||i())){var h;if(o){if(!(o>=16))return;var y=Y();h={elementIds:[],nose:{blocked:!1,index:null,pointer:null},tail:{blocked:!1,index:null,pointer:null},id:y,interval:Math.abs(o)}}var m;n(c,function(e){m||e.node!==f||(m=e.id)}),isNaN(m)&&(m=Y());try{n(p.map(function(t){var n={},i=t.getAttribute("data-sr-id");return i?(e(n,a.store.elements[i]),n.node.setAttribute("style",n.styles.inline)):(n.id=Y(),n.node=t,n.seen=!1,n.revealed=!1,n.visible=!1),n.config=l,n.containerId=m,n.styles=A(n),h&&(n.sequence={id:h.id,index:h.elementIds.length},h.elementIds.push(n.id)),n}),function(e){a.store.elements[e.id]=e,e.node.setAttribute("data-sr-id",e.id)})}catch(e){return}c[m]=c[m]||{id:m,node:f},h&&(this.store.sequences[h.id]=h),s||(this.store.history.push({target:t,options:r,interval:o}),this.initTimeout&&window.clearTimeout(this.initTimeout),this.initTimeout=window.setTimeout(q.bind(this),0))}}function L(){var e=this;n(this.store.history,function(t){O.call(e,t.target,t.options,t.interval,!0)}),q.call(this)}function I(e,t){var n=this.store.sequences[e.sequence.id],i="always"===e.config.useDelay||"onload"===e.config.useDelay&&this.pristine||"once"===e.config.useDelay&&!e.seen;if(e.visible=l.call(this,e),t){if(e.sequence.index===n.nose.pointer-1&&n.nose.pointer>n.nose.index)n.nose.pointer--,P.call(this,n);else{if(!(e.sequence.index===n.tail.pointer+1&&n.tail.pointer<n.tail.index))return;n.tail.pointer++,F.call(this,n)}return M.call(this,e,i)}if(e.visible&&!e.revealed){if(n)if(z.call(this,n),null===n.nose.pointer&&null===n.tail.pointer)n.nose.pointer=n.tail.pointer=e.sequence.index,P.call(this,n),F.call(this,n);else if(e.sequence.index!==n.nose.pointer-1||n.nose.blocked){if(e.sequence.index!==n.tail.pointer+1||n.tail.blocked)return;n.tail.pointer++,F.call(this,n)}else n.nose.pointer--,P.call(this,n);return e.seen=!0,M.call(this,e,i)}if(!e.visible&&e.revealed&&e.config.reset)return n&&(z.call(this,n),n.nose.index!==1/0&&n.tail.index!==-1/0&&(n.nose.pointer=Math.max(n.nose.pointer,n.nose.index),n.tail.pointer=Math.min(n.tail.pointer,n.tail.index))),R.call(this,e)}function M(e,t){var n=[e.styles.inline,e.styles.opacity.computed,e.styles.transform.generated.final];t?n.push(e.styles.transition.generated.delayed):n.push(e.styles.transition.generated.instant),e.revealed=!0,e.node.setAttribute("style",n.filter(function(e){return""!==e}).join(" ")),N.call(this,e,t)}function R(e){var t=[e.styles.inline,e.styles.opacity.generated,e.styles.transform.generated.initial,e.styles.transition.generated.instant];e.revealed=!1,e.node.setAttribute("style",t.filter(function(e){return""!==e}).join(" ")),N.call(this,e)}function N(e,t){var n=this,i=t?e.config.duration+e.config.delay:e.config.duration,r=e.revealed?e.config.beforeReveal:e.config.beforeReset,o=e.revealed?e.config.afterReveal:e.config.afterReset,s=0;e.callbackTimer&&(s=Date.now()-e.callbackTimer.start,window.clearTimeout(e.callbackTimer.clock)),r(e.node),e.callbackTimer={start:Date.now(),clock:window.setTimeout(function(){o(e.node),e.callbackTimer=null,e.revealed&&!e.config.reset&&h.call(n,e.node)},i-s)}}function z(e){var t=this,i=1/0,r=-1/0;n(e.elementIds,function(e){var n=t.store.elements[e];n&&n.visible&&(i=Math.min(i,n.sequence.index),r=Math.max(r,n.sequence.index))}),e.nose.index=i,e.tail.index=r}function P(e){var t=this,n=e.elementIds[e.nose.pointer-1],i=this.store.elements[n];i&&(e.nose.blocked=!0,window.setTimeout(function(){e.nose.blocked=!1,I.call(t,i,!0)},e.interval))}function F(e){var t=this,n=e.elementIds[e.tail.pointer+1],i=this.store.elements[n];i&&(e.tail.blocked=!0,window.setTimeout(function(){e.tail.blocked=!1,I.call(t,i,!0)},e.interval))}function S(e){var t=this;void 0===e&&(e={}),B(function(){var i=t.store.containers,r=t.store.elements;switch(e.type){case"scroll":n(i,function(e){return e.scroll=f.call(t,e)}),n(r,function(e){return I.call(t,e)});break;case"resize":default:n(i,function(e){e.geometry=c.call(t,e,!0),e.scroll=f.call(t,e)}),n(r,function(e){e.geometry=c.call(t,e),I.call(t,e)})}t.pristine=!1})}function D(t){if(void 0===t&&(t={}),void 0===this||Object.getPrototypeOf(this)!==D.prototype)return new D(t);if(!D.isSupported())return W;try{Object.defineProperty(this,"defaults",{get:function(){var n={};return e(n,C,t),function(){return n}}()})}catch(e){return W}if(!u(this.defaults.container))return W;this.defaults.mobile!==i()&&this.defaults.desktop!==!i()||document.documentElement.classList.add("sr"),this.store={containers:{},elements:{},history:[],sequences:{}},this.pristine=!0,this.delegate=S.bind(this),Object.defineProperty(this,"version",{get:function(){return U}}),Object.defineProperty(this,"noop",{get:function(){return!1}})}var C={origin:"bottom",distance:"0",duration:600,delay:0,rotate:{x:0,y:0,z:0},opacity:0,scale:1,easing:"cubic-bezier(0.6, 0.2, 0.1, 1)",container:document.documentElement,desktop:!0,mobile:!0,reset:!1,useDelay:"always",viewFactor:0,viewOffset:{top:0,right:0,bottom:0,left:0},beforeReveal:function(){},beforeReset:function(){},afterReveal:function(){},afterReset:function(){}},W={clean:function(){},destroy:function(){},reveal:function(){},sync:function(){},get noop(){return!0}},Y=function(){var e=0;return function(){return e++}}(),$=function(){function e(e,i){if(void 0===i&&(i=n),e&&"string"==typeof e){if(t[e])return t[e];if("string"==typeof i[e])return t[e]=e;if("string"==typeof i["-webkit-"+e])return t[e]="-webkit-"+e;throw new RangeError('Unable to find "'+e+'" style property.')}throw new TypeError("Expected a string.")}var t={},n=document.documentElement.style;return e.clearCache=function(){return t={}},e}(),H=function(){var e=Date.now();return function(t){var n=Date.now();n-e>16?(e=n,t(n)):setTimeout(function(){return H(t)},0)}}(),B=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||H,U="4.0.0-beta.5";return D.isSupported=function(){return s()&&a()},D.prototype.clean=h,D.prototype.destroy=y,D.prototype.reveal=O,D.prototype.sync=L,D}(); |
{ | ||
"name": "scrollreveal", | ||
"version": "4.0.0-beta.4", | ||
"version": "4.0.0-beta.5", | ||
"description": "Easy scroll animations for web and mobile browsers.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://scrollrevealjs.org", |
@@ -129,3 +129,3 @@ import { isElementVisible } from '../../utils/core' | ||
const element = this.store.elements[id] | ||
if (element.visible) { | ||
if (element && element.visible) { | ||
min = Math.min(min, element.sequence.index) | ||
@@ -132,0 +132,0 @@ max = Math.max(max, element.sequence.index) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
237864