scrollreveal
Advanced tools
Comparing version 4.0.0-beta.22 to 4.0.0-beta.23
@@ -29,2 +29,3 @@ # Change Log | ||
- ScrollReveal `version` is now a read-only instance property. | ||
- ScrollReveal methods are now bound read-only instance properties. | ||
- `options.viewFactor` clamps values outside of `0.0` to `1.0`. | ||
@@ -31,0 +32,0 @@ - ScrollReveal constructor now returns a singleton. |
@@ -1,2 +0,2 @@ | ||
/*! @license ScrollReveal v4.0.0-beta.22 | ||
/*! @license ScrollReveal v4.0.0-beta.23 | ||
@@ -1377,3 +1377,3 @@ Copyright 2017 Fisssion LLC. | ||
var version = "4.0.0-beta.22"; | ||
var version = "4.0.0-beta.23"; | ||
@@ -1456,2 +1456,7 @@ var _config; | ||
Object.defineProperty(this, 'delegate', { get: function () { return delegate.bind(this$1); } }); | ||
Object.defineProperty(this, 'destroy', { get: function () { return destroy.bind(this$1); } }); | ||
Object.defineProperty(this, 'reveal', { get: function () { return reveal.bind(this$1); } }); | ||
Object.defineProperty(this, 'clean', { get: function () { return clean.bind(this$1); } }); | ||
Object.defineProperty(this, 'sync', { get: function () { return sync.bind(this$1); } }); | ||
Object.defineProperty(this, 'version', { get: function () { return version; } }); | ||
@@ -1476,11 +1481,2 @@ Object.defineProperty(this, 'noop', { get: function () { return false; } }); | ||
/** | ||
* The primary API is comprised | ||
* of these instance methods: | ||
*/ | ||
ScrollReveal.prototype.clean = clean; | ||
ScrollReveal.prototype.destroy = destroy; | ||
ScrollReveal.prototype.reveal = reveal; | ||
ScrollReveal.prototype.sync = sync; | ||
export default ScrollReveal; |
@@ -1,2 +0,2 @@ | ||
/*! @license ScrollReveal v4.0.0-beta.22 | ||
/*! @license ScrollReveal v4.0.0-beta.23 | ||
@@ -1383,3 +1383,3 @@ Copyright 2017 Fisssion LLC. | ||
var version = "4.0.0-beta.22"; | ||
var version = "4.0.0-beta.23"; | ||
@@ -1462,2 +1462,7 @@ var _config; | ||
Object.defineProperty(this, 'delegate', { get: function () { return delegate.bind(this$1); } }); | ||
Object.defineProperty(this, 'destroy', { get: function () { return destroy.bind(this$1); } }); | ||
Object.defineProperty(this, 'reveal', { get: function () { return reveal.bind(this$1); } }); | ||
Object.defineProperty(this, 'clean', { get: function () { return clean.bind(this$1); } }); | ||
Object.defineProperty(this, 'sync', { get: function () { return sync.bind(this$1); } }); | ||
Object.defineProperty(this, 'version', { get: function () { return version; } }); | ||
@@ -1482,13 +1487,4 @@ Object.defineProperty(this, 'noop', { get: function () { return false; } }); | ||
/** | ||
* The primary API is comprised | ||
* of these instance methods: | ||
*/ | ||
ScrollReveal.prototype.clean = clean; | ||
ScrollReveal.prototype.destroy = destroy; | ||
ScrollReveal.prototype.reveal = reveal; | ||
ScrollReveal.prototype.sync = sync; | ||
return ScrollReveal; | ||
}))); |
@@ -1,2 +0,2 @@ | ||
/*! @license ScrollReveal v4.0.0-beta.22 | ||
/*! @license ScrollReveal v4.0.0-beta.23 | ||
@@ -12,2 +12,2 @@ Copyright 2017 Fisssion LLC. | ||
*/ | ||
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);return"object"==typeof window.NodeList?e instanceof window.NodeList:"object"==typeof e&&"number"==typeof e.length&&/^\[object (HTMLCollection|NodeList|Object)\]$/.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=Math.max(0,Math.min(1,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(t){throw new Error('"'+e+'" is not a valid selector.')}if(!n)throw new Error('The selector "'+e+'" matches 0 elements.')}return r(e)?e:n}function d(e,t){if(void 0===t&&(t=document),e instanceof Array)return e;if(r(e))return[e];if(o(e))return Array.prototype.slice.call(e);if("string"==typeof e){var n;try{n=t.querySelectorAll(e)}catch(t){throw new Error('"'+e+'" is not a valid selector.')}return Array.prototype.slice.call(n)}}function f(e){return e.node===document.documentElement?{top:window.pageYOffset,left:window.pageXOffset}:{top:e.node.scrollTop,left:e.node.scrollLeft}}function h(e){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];if(this.constructor.debug&&console){var i="%cScrollReveal: "+e;t.forEach(function(e){return i+="\n β "+e}),console.log(i,"color: #ea654b;")}}function p(){var e=this,t={active:[],stale:[]},i={active:[],stale:[]},r={active:[],stale:[]};try{n(d("[data-sr-id]"),function(e){var n=parseInt(e.getAttribute("data-sr-id"));t.active.push(n)})}catch(e){throw e}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===r.active.indexOf(e.containerId)&&r.active.push(e.containerId),e.hasOwnProperty("sequence")&&-1===i.active.indexOf(e.sequence.id)&&i.active.push(e.sequence.id)}),n(this.store.containers,function(e){-1===r.active.indexOf(e.id)&&r.stale.push(e.id)}),n(r.stale,function(t){var n=e.store.containers[t].node;n.removeEventListener("scroll",e.delegate),n.removeEventListener("resize",e.delegate),delete e.store.containers[t]}),n(this.store.sequences,function(e){-1===i.active.indexOf(e.id)&&i.stale.push(e.id)}),n(i.stale,function(t){return delete e.store.sequences[t]})}function m(e){var t,i=this;try{n(d(e),function(e){var n=e.getAttribute("data-sr-id");if(null!==n){t=!0;var r=i.store.elements[n];r.callbackTimer&&window.clearTimeout(r.callbackTimer.clock),e.setAttribute("style",r.styles.inline.generated),e.removeAttribute("data-sr-id"),delete i.store.elements[n]}})}catch(e){return h.call(this,"Clean failed.",e.stack||e.message)}if(t)try{p.call(this)}catch(e){return h.call(this,"Clean failed.",e.stack||e.message)}}function y(e){if(e.constructor!==Array)throw new TypeError("Expected array.");if(16===e.length)return e;if(6===e.length){var t=v();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 v(){for(var e=[],t=0;t<16;t++)t%5==0?e.push(1):e.push(0);return e}function g(e,t){for(var n=y(e),i=y(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 y(t[2].split(", ").map(parseFloat))}return v()}function w(e){var t=Math.PI/180*e,n=v();return n[5]=n[10]=Math.cos(t),n[6]=n[9]=Math.sin(t),n[9]*=-1,n}function E(e){var t=Math.PI/180*e,n=v();return n[0]=n[10]=Math.cos(t),n[2]=n[8]=Math.sin(t),n[2]*=-1,n}function k(e){var t=Math.PI/180*e,n=v();return n[0]=n[5]=Math.cos(t),n[1]=n[4]=Math.sin(t),n[4]*=-1,n}function T(e,t){var n=v();return n[0]=e,n[5]="number"==typeof t?t:e,n}function j(e){var t=v();return t[12]=e,t}function x(e){var t=v();return t[13]=e,t}function R(e){var t=window.getComputedStyle(e.node),n=t.position,i=e.config,r={},o=(e.node.getAttribute("style")||"").match(/[\w-]+\s*:\s*[^;]+\s*/gi)||[];r.computed=o?o.map(function(e){return e.trim()}).join("; ")+";":"",r.generated=o.some(function(e){return e.match(/visibility\s?:\s?visible/i)})?r.computed:o.concat(["visibility: visible"]).map(function(e){return e.trim()}).join("; ")+";";var s=parseFloat(t.opacity),a=isNaN(parseFloat(i.opacity))?parseFloat(t.opacity):parseFloat(i.opacity),l={computed:s!==a?"opacity: "+s+";":"",generated:s!==a?"opacity: "+a+";":""},c=[];if(parseFloat(i.distance)){var u="top"===i.origin||"bottom"===i.origin?"Y":"X",d=i.distance;"top"!==i.origin&&"left"!==i.origin||(d=/^-/.test(d)?d.substr(1):"-"+d);var f=d.match(/(^-?\d+\.?\d?)|(em$|px$|%$)/g),h=f[0];switch(f[1]){case"em":d=parseInt(t.fontSize)*h;break;case"px":d=h;break;case"%":d="Y"===u?e.node.getBoundingClientRect().height*h/100:e.node.getBoundingClientRect().width*h/100;break;default:throw new RangeError("Unrecognized or missing distance unit.")}"Y"===u?c.push(x(d)):c.push(j(d))}i.rotate.x&&c.push(w(i.rotate.x)),i.rotate.y&&c.push(E(i.rotate.y)),i.rotate.z&&c.push(k(i.rotate.z)),1!==i.scale&&(0===i.scale?c.push(T(2e-4)):c.push(T(i.scale)));var p={};if(c.length){p.property=X("transform"),p.computed={raw:t[p.property],matrix:b(t[p.property])},c.unshift(p.computed.matrix);var m=c.reduce(g);p.generated={initial:p.property+": matrix3d("+m.join(", ")+");",final:p.property+": matrix3d("+p.computed.matrix.join(", ")+");"}}else p.generated={initial:"",final:""};var y={};if(l.generated||p.generated.initial){y.property=X("transition"),y.computed=t[y.property],y.fragments=[];var v=i.delay,R=i.duration,A=i.easing;l.generated&&y.fragments.push({delayed:"opacity "+R/1e3+"s "+A+" "+v/1e3+"s",instant:"opacity "+R/1e3+"s "+A+" 0s"}),p.generated.initial&&y.fragments.push({delayed:p.property+" "+R/1e3+"s "+A+" "+v/1e3+"s",instant:p.property+" "+R/1e3+"s "+A+" 0s"}),y.computed&&!y.computed.match(/all 0s/)&&y.fragments.unshift({delayed:y.computed,instant:y.computed});var O=y.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:""});y.generated={delayed:y.property+": "+O.delayed+";",instant:y.property+": "+O.instant+";"}}else y.generated={delayed:"",instant:""};return{inline:r,opacity:l,position:n,transform:p,transition:y}}function A(){var e=this;p.call(this),n(this.store.elements,function(e){var t=[e.styles.inline.generated];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){var n=t.node===document.documentElement?window:t.node;n.addEventListener("scroll",e.delegate),n.addEventListener("resize",e.delegate)}),this.delegate(),this.initTimeout=null}function O(e,t){void 0===t&&(t={});var n=t.pristine||this.pristine,i="always"===e.config.useDelay||"onload"===e.config.useDelay&&n||"once"===e.config.useDelay&&!e.seen,r=e.visible&&!e.revealed,o=!e.visible&&e.revealed&&e.config.reset;return r||t.reveal?q.call(this,e,i):o||t.reset?I.call(this,e):void 0}function q(e,t){var n=[e.styles.inline.generated,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=e.seen=!0,e.node.setAttribute("style",n.filter(function(e){return""!==e}).join(" ")),L.call(this,e,t)}function I(e){var t=[e.styles.inline.generated,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(" ")),L.call(this,e)}function L(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&&m.call(n,e.node)},i-s)}}function M(e,t){void 0===t&&(t=this.pristine);var n=this.store.sequences[e.sequence.id],i=e.sequence.index;if(n){var r=new N("visible",n,this.store),o=new N("revealed",n,this.store);if(n.models={visible:r,revealed:o},!o.body.length){var s=n.members[r.body[0]],a=this.store.elements[s];return a?(z.call(this,n,r.body[0],-1,t),z.call(this,n,r.body[0],1,t),n.lastReveal=r.body[0],O.call(this,a,{reveal:!0,pristine:t})):O.call(this,e)}if(!e.visible&&e.revealed&&e.config.reset)return n.lastReset=i,O.call(this,e,{reset:!0});if(!n.headblocked&&i===[].concat(o.head).pop()&&i>=[].concat(r.body).shift())return z.call(this,n,i,-1,t),n.lastReveal=i,O.call(this,e,{reveal:!0,pristine:t});if(!n.footblocked&&i===[].concat(o.foot).shift()&&i<=[].concat(r.body).pop())return z.call(this,n,i,1,t),n.lastReveal=i,O.call(this,e,{reveal:!0,pristine:t})}}function P(e){if("number"!=typeof e)return null;if(!(e>=16))throw new RangeError("Sequence interval must be at least 16ms.");this.id=U(),this.interval=e,this.members=[],this.headblocked=!0,this.footblocked=!0,this.lastReveal=null,this.lastReset=null,this.models={}}function N(e,t,i){var r=this;this.head=[],this.body=[],this.foot=[],n(t.members,function(t,n){var o=i.elements[t];o&&o[e]&&r.body.push(n)}),this.body.length&&n(t.members,function(t,n){var o=i.elements[t];o&&!o[e]&&(n<r.body[0]?r.head.push(n):r.foot.push(n))})}function z(e,t,n,i){var r=this,o=["headblocked",null,"footblocked"][1+n],s=e.members[t+n],a=this.store.elements[s];e[o]=!0,setTimeout(function(){e[o]=!1,a&&M.call(r,a,i)},e.interval)}function F(t,r,o,s){var a=this,l=[];"number"==typeof r?(o=parseInt(r),r={}):(o=parseInt(o),r=r||{});var c,f;try{c=d(t),f=o?new P(o):null}catch(e){return h.call(this,"Reveal failed.",e.stack||e.message)}try{n(c.reduce(function(t,n){var o={},s=n.getAttribute("data-sr-id");s?(e(o,a.store.elements[s]),o.node.setAttribute("style",o.styles.inline.computed)):(o.id=U(),o.node=n,o.seen=!1,o.revealed=!1,o.visible=!1);var c,d=e({},o.config||a.defaults,r);if(null==c&&(c=!d.mobile&&i()||!d.desktop&&!i()),c)return s&&m.call(a,o),t;var h,p=u(d.container);if(!p)throw new Error("Invalid container.");return p.contains(n)?(null==(h=S(p,l,a.store.containers))&&(h=U(),l.push({id:h,node:p})),o.config=d,o.containerId=h,o.styles=R(o),f&&(o.sequence={id:f.id,index:f.members.length},f.members.push(o.id)),t.push(o),t):t},[]),function(e){a.store.elements[e.id]=e,e.node.setAttribute("data-sr-id",e.id)})}catch(e){return h.call(this,"Reveal failed.",e.stack||e.message)}n(l,function(e){a.store.containers[e.id]={id:e.id,node:e.node}}),f&&(this.store.sequences[f.id]=f),s||(this.store.history.push({target:t,options:r,interval:o}),this.initTimeout&&window.clearTimeout(this.initTimeout),this.initTimeout=window.setTimeout(A.bind(this),0))}function S(e){for(var t=[],i=arguments.length-1;i-- >0;)t[i]=arguments[i+1];var r=null;return n(t,function(t){n(t,function(t){null===r&&t.node===e&&(r=t.id)})}),r}function D(e,t){var i=this;void 0===e&&(e={type:"init"}),void 0===t&&(t=this.store.elements),K(function(){var r="init"===e.type||"resize"===e.type;n(i.store.containers,function(e){r&&(e.geometry=c.call(i,e,!0));var t=f.call(i,e);e.scroll&&(e.direction={x:G(t.left-e.scroll.left),y:G(t.top-e.scroll.top)}),e.scroll=t}),n(t,function(e){r&&(e.geometry=c.call(i,e)),e.visible=l.call(i,e)}),n(t,function(e){e.sequence?M.call(i,e):O.call(i,e)}),i.pristine=!1})}function C(t){var n=this;if(void 0===t&&(t={}),void 0===this||Object.getPrototypeOf(this)!==C.prototype)return new C(t);if(!C.isSupported())return h.call(this,"Instantiation aborted.","This browser is not supported."),B;var r;try{r=W?e({},W,t):e({},H,t)}catch(e){return h.call(this,"Instantiation failed.","Invalid configuration.",e.message),B}try{if(!u(r.container))throw new Error("Invalid container.")}catch(e){return h.call(this,"Instantiation failed.",e.message),B}return W=r,Object.defineProperty(this,"defaults",{get:function(){return W}}),this.defaults.mobile!==i()&&this.defaults.desktop!==!i()||(document.documentElement.classList.add("sr"),document.body?document.body.style.height="100%":document.addEventListener("DOMContentLoaded",function(){document.body.style.height="100%"})),this.store={containers:{},elements:{},history:[],sequences:{}},this.pristine=!0,Object.defineProperty(this,"delegate",{get:function(){return D.bind(n)}}),Object.defineProperty(this,"version",{get:function(){return Q}}),Object.defineProperty(this,"noop",{get:function(){return!1}}),$||($=this)}var W,Y,$,H={delay:0,distance:"0",duration:600,easing:"cubic-bezier(0.6, 0.2, 0.1, 1)",opacity:0,origin:"bottom",rotate:{x:0,y:0,z:0},scale:1,container:document.documentElement,desktop:!0,mobile:!0,reset:!1,useDelay:"always",viewFactor:0,viewOffset:{top:0,right:0,bottom:0,left:0},afterReset:function(){},afterReveal:function(){},beforeReset:function(){},beforeReveal:function(){}},B={clean:function(){},destroy:function(){},reveal:function(){},sync:function(){},get noop(){return!0}},U=function(){var e=0;return function(){return e++}}(),X=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}(),G=Math.sign||function(e){return(e>0)-(e<0)||+e},J=function(){var e=Date.now();return function(t){var n=Date.now();n-e>16?(e=n,t(n)):setTimeout(function(){return J(t)},0)}}(),K=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||J,Q="4.0.0-beta.22";return C.isSupported=function(){return s()&&a()},Object.defineProperty(C,"debug",{get:function(){return Y||!1},set:function(e){"boolean"==typeof e&&(Y=e)}}),C.prototype.clean=m,C.prototype.destroy=function(){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){var n=t.node===document.documentElement?window:t.node;n.removeEventListener("scroll",e.delegate),n.removeEventListener("resize",e.delegate)}),this.store={containers:{},elements:{},history:[],sequences:{}}},C.prototype.reveal=F,C.prototype.sync=function(){var e=this;n(this.store.history,function(t){F.call(e,t.target,t.options,t.interval,!0)}),A.call(this)},C}(); | ||
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);return"object"==typeof window.NodeList?e instanceof window.NodeList:"object"==typeof e&&"number"==typeof e.length&&/^\[object (HTMLCollection|NodeList|Object)\]$/.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 c(e){var t=this.store.containers[e.containerId],n=Math.max(0,Math.min(1,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 l(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(t){throw new Error('"'+e+'" is not a valid selector.')}if(!n)throw new Error('The selector "'+e+'" matches 0 elements.')}return r(e)?e:n}function d(e,t){if(void 0===t&&(t=document),e instanceof Array)return e;if(r(e))return[e];if(o(e))return Array.prototype.slice.call(e);if("string"==typeof e){var n;try{n=t.querySelectorAll(e)}catch(t){throw new Error('"'+e+'" is not a valid selector.')}return Array.prototype.slice.call(n)}}function f(e){return e.node===document.documentElement?{top:window.pageYOffset,left:window.pageXOffset}:{top:e.node.scrollTop,left:e.node.scrollLeft}}function h(e){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];if(this.constructor.debug&&console){var i="%cScrollReveal: "+e;t.forEach(function(e){return i+="\n β "+e}),console.log(i,"color: #ea654b;")}}function p(){var e=this,t={active:[],stale:[]},i={active:[],stale:[]},r={active:[],stale:[]};try{n(d("[data-sr-id]"),function(e){var n=parseInt(e.getAttribute("data-sr-id"));t.active.push(n)})}catch(e){throw e}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===r.active.indexOf(e.containerId)&&r.active.push(e.containerId),e.hasOwnProperty("sequence")&&-1===i.active.indexOf(e.sequence.id)&&i.active.push(e.sequence.id)}),n(this.store.containers,function(e){-1===r.active.indexOf(e.id)&&r.stale.push(e.id)}),n(r.stale,function(t){var n=e.store.containers[t].node;n.removeEventListener("scroll",e.delegate),n.removeEventListener("resize",e.delegate),delete e.store.containers[t]}),n(this.store.sequences,function(e){-1===i.active.indexOf(e.id)&&i.stale.push(e.id)}),n(i.stale,function(t){return delete e.store.sequences[t]})}function m(e){var t,i=this;try{n(d(e),function(e){var n=e.getAttribute("data-sr-id");if(null!==n){t=!0;var r=i.store.elements[n];r.callbackTimer&&window.clearTimeout(r.callbackTimer.clock),e.setAttribute("style",r.styles.inline.generated),e.removeAttribute("data-sr-id"),delete i.store.elements[n]}})}catch(e){return h.call(this,"Clean failed.",e.stack||e.message)}if(t)try{p.call(this)}catch(e){return h.call(this,"Clean failed.",e.stack||e.message)}}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){var n=t.node===document.documentElement?window:t.node;n.removeEventListener("scroll",e.delegate),n.removeEventListener("resize",e.delegate)}),this.store={containers:{},elements:{},history:[],sequences:{}}}function v(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 b(e,t){for(var n=v(e),i=v(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 c=4*a,l=[i[c],i[c+1],i[c+2],i[c+3]],u=s[0]*l[0]+s[1]*l[1]+s[2]*l[2]+s[3]*l[3];r[o+c]=u}return r}function w(e){if("string"==typeof e){var t=e.match(/matrix(3d)?\(([^)]+)\)/);if(t)return v(t[2].split(", ").map(parseFloat))}return g()}function E(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 j(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 k(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 T(e,t){var n=g();return n[0]=e,n[5]="number"==typeof t?t:e,n}function O(e){var t=g();return t[12]=e,t}function x(e){var t=g();return t[13]=e,t}function R(e){var t=window.getComputedStyle(e.node),n=t.position,i=e.config,r={},o=(e.node.getAttribute("style")||"").match(/[\w-]+\s*:\s*[^;]+\s*/gi)||[];r.computed=o?o.map(function(e){return e.trim()}).join("; ")+";":"",r.generated=o.some(function(e){return e.match(/visibility\s?:\s?visible/i)})?r.computed:o.concat(["visibility: visible"]).map(function(e){return e.trim()}).join("; ")+";";var s=parseFloat(t.opacity),a=isNaN(parseFloat(i.opacity))?parseFloat(t.opacity):parseFloat(i.opacity),c={computed:s!==a?"opacity: "+s+";":"",generated:s!==a?"opacity: "+a+";":""},l=[];if(parseFloat(i.distance)){var u="top"===i.origin||"bottom"===i.origin?"Y":"X",d=i.distance;"top"!==i.origin&&"left"!==i.origin||(d=/^-/.test(d)?d.substr(1):"-"+d);var f=d.match(/(^-?\d+\.?\d?)|(em$|px$|%$)/g),h=f[0];switch(f[1]){case"em":d=parseInt(t.fontSize)*h;break;case"px":d=h;break;case"%":d="Y"===u?e.node.getBoundingClientRect().height*h/100:e.node.getBoundingClientRect().width*h/100;break;default:throw new RangeError("Unrecognized or missing distance unit.")}"Y"===u?l.push(x(d)):l.push(O(d))}i.rotate.x&&l.push(E(i.rotate.x)),i.rotate.y&&l.push(j(i.rotate.y)),i.rotate.z&&l.push(k(i.rotate.z)),1!==i.scale&&(0===i.scale?l.push(T(2e-4)):l.push(T(i.scale)));var p={};if(l.length){p.property=J("transform"),p.computed={raw:t[p.property],matrix:w(t[p.property])},l.unshift(p.computed.matrix);var m=l.reduce(b);p.generated={initial:p.property+": matrix3d("+m.join(", ")+");",final:p.property+": matrix3d("+p.computed.matrix.join(", ")+");"}}else p.generated={initial:"",final:""};var y={};if(c.generated||p.generated.initial){y.property=J("transition"),y.computed=t[y.property],y.fragments=[];var v=i.delay,g=i.duration,R=i.easing;c.generated&&y.fragments.push({delayed:"opacity "+g/1e3+"s "+R+" "+v/1e3+"s",instant:"opacity "+g/1e3+"s "+R+" 0s"}),p.generated.initial&&y.fragments.push({delayed:p.property+" "+g/1e3+"s "+R+" "+v/1e3+"s",instant:p.property+" "+g/1e3+"s "+R+" 0s"}),y.computed&&!y.computed.match(/all 0s/)&&y.fragments.unshift({delayed:y.computed,instant:y.computed});var A=y.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:""});y.generated={delayed:y.property+": "+A.delayed+";",instant:y.property+": "+A.instant+";"}}else y.generated={delayed:"",instant:""};return{inline:r,opacity:c,position:n,transform:p,transition:y}}function A(){var e=this;p.call(this),n(this.store.elements,function(e){var t=[e.styles.inline.generated];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){var n=t.node===document.documentElement?window:t.node;n.addEventListener("scroll",e.delegate),n.addEventListener("resize",e.delegate)}),this.delegate(),this.initTimeout=null}function q(e,t){void 0===t&&(t={});var n=t.pristine||this.pristine,i="always"===e.config.useDelay||"onload"===e.config.useDelay&&n||"once"===e.config.useDelay&&!e.seen,r=e.visible&&!e.revealed,o=!e.visible&&e.revealed&&e.config.reset;return r||t.reveal?P.call(this,e,i):o||t.reset?I.call(this,e):void 0}function P(e,t){var n=[e.styles.inline.generated,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=e.seen=!0,e.node.setAttribute("style",n.filter(function(e){return""!==e}).join(" ")),L.call(this,e,t)}function I(e){var t=[e.styles.inline.generated,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(" ")),L.call(this,e)}function L(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&&m.call(n,e.node)},i-s)}}function M(e,t){void 0===t&&(t=this.pristine);var n=this.store.sequences[e.sequence.id],i=e.sequence.index;if(n){var r=new z("visible",n,this.store),o=new z("revealed",n,this.store);if(n.models={visible:r,revealed:o},!o.body.length){var s=n.members[r.body[0]],a=this.store.elements[s];return a?(F.call(this,n,r.body[0],-1,t),F.call(this,n,r.body[0],1,t),n.lastReveal=r.body[0],q.call(this,a,{reveal:!0,pristine:t})):q.call(this,e)}if(!e.visible&&e.revealed&&e.config.reset)return n.lastReset=i,q.call(this,e,{reset:!0});if(!n.headblocked&&i===[].concat(o.head).pop()&&i>=[].concat(r.body).shift())return F.call(this,n,i,-1,t),n.lastReveal=i,q.call(this,e,{reveal:!0,pristine:t});if(!n.footblocked&&i===[].concat(o.foot).shift()&&i<=[].concat(r.body).pop())return F.call(this,n,i,1,t),n.lastReveal=i,q.call(this,e,{reveal:!0,pristine:t})}}function N(e){if("number"!=typeof e)return null;if(!(e>=16))throw new RangeError("Sequence interval must be at least 16ms.");this.id=G(),this.interval=e,this.members=[],this.headblocked=!0,this.footblocked=!0,this.lastReveal=null,this.lastReset=null,this.models={}}function z(e,t,i){var r=this;this.head=[],this.body=[],this.foot=[],n(t.members,function(t,n){var o=i.elements[t];o&&o[e]&&r.body.push(n)}),this.body.length&&n(t.members,function(t,n){var o=i.elements[t];o&&!o[e]&&(n<r.body[0]?r.head.push(n):r.foot.push(n))})}function F(e,t,n,i){var r=this,o=["headblocked",null,"footblocked"][1+n],s=e.members[t+n],a=this.store.elements[s];e[o]=!0,setTimeout(function(){e[o]=!1,a&&M.call(r,a,i)},e.interval)}function S(t,r,o,s){var a=this,c=[];"number"==typeof r?(o=parseInt(r),r={}):(o=parseInt(o),r=r||{});var l,f;try{l=d(t),f=o?new N(o):null}catch(e){return h.call(this,"Reveal failed.",e.stack||e.message)}try{n(l.reduce(function(t,n){var o={},s=n.getAttribute("data-sr-id");s?(e(o,a.store.elements[s]),o.node.setAttribute("style",o.styles.inline.computed)):(o.id=G(),o.node=n,o.seen=!1,o.revealed=!1,o.visible=!1);var l,d=e({},o.config||a.defaults,r);if(null==l&&(l=!d.mobile&&i()||!d.desktop&&!i()),l)return s&&m.call(a,o),t;var h,p=u(d.container);if(!p)throw new Error("Invalid container.");return p.contains(n)?(null==(h=D(p,c,a.store.containers))&&(h=G(),c.push({id:h,node:p})),o.config=d,o.containerId=h,o.styles=R(o),f&&(o.sequence={id:f.id,index:f.members.length},f.members.push(o.id)),t.push(o),t):t},[]),function(e){a.store.elements[e.id]=e,e.node.setAttribute("data-sr-id",e.id)})}catch(e){return h.call(this,"Reveal failed.",e.stack||e.message)}n(c,function(e){a.store.containers[e.id]={id:e.id,node:e.node}}),f&&(this.store.sequences[f.id]=f),s||(this.store.history.push({target:t,options:r,interval:o}),this.initTimeout&&window.clearTimeout(this.initTimeout),this.initTimeout=window.setTimeout(A.bind(this),0))}function D(e){for(var t=[],i=arguments.length-1;i-- >0;)t[i]=arguments[i+1];var r=null;return n(t,function(t){n(t,function(t){null===r&&t.node===e&&(r=t.id)})}),r}function C(){var e=this;n(this.store.history,function(t){S.call(e,t.target,t.options,t.interval,!0)}),A.call(this)}function W(e,t){var i=this;void 0===e&&(e={type:"init"}),void 0===t&&(t=this.store.elements),V(function(){var r="init"===e.type||"resize"===e.type;n(i.store.containers,function(e){r&&(e.geometry=l.call(i,e,!0));var t=f.call(i,e);e.scroll&&(e.direction={x:K(t.left-e.scroll.left),y:K(t.top-e.scroll.top)}),e.scroll=t}),n(t,function(e){r&&(e.geometry=l.call(i,e)),e.visible=c.call(i,e)}),n(t,function(e){e.sequence?M.call(i,e):q.call(i,e)}),i.pristine=!1})}function Y(t){var n=this;if(void 0===t&&(t={}),void 0===this||Object.getPrototypeOf(this)!==Y.prototype)return new Y(t);if(!Y.isSupported())return h.call(this,"Instantiation aborted.","This browser is not supported."),X;var r;try{r=$?e({},$,t):e({},U,t)}catch(e){return h.call(this,"Instantiation failed.","Invalid configuration.",e.message),X}try{if(!u(r.container))throw new Error("Invalid container.")}catch(e){return h.call(this,"Instantiation failed.",e.message),X}return $=r,Object.defineProperty(this,"defaults",{get:function(){return $}}),this.defaults.mobile!==i()&&this.defaults.desktop!==!i()||(document.documentElement.classList.add("sr"),document.body?document.body.style.height="100%":document.addEventListener("DOMContentLoaded",function(){document.body.style.height="100%"})),this.store={containers:{},elements:{},history:[],sequences:{}},this.pristine=!0,Object.defineProperty(this,"delegate",{get:function(){return W.bind(n)}}),Object.defineProperty(this,"destroy",{get:function(){return y.bind(n)}}),Object.defineProperty(this,"reveal",{get:function(){return S.bind(n)}}),Object.defineProperty(this,"clean",{get:function(){return m.bind(n)}}),Object.defineProperty(this,"sync",{get:function(){return C.bind(n)}}),Object.defineProperty(this,"version",{get:function(){return Z}}),Object.defineProperty(this,"noop",{get:function(){return!1}}),B||(B=this)}var $,H,B,U={delay:0,distance:"0",duration:600,easing:"cubic-bezier(0.6, 0.2, 0.1, 1)",opacity:0,origin:"bottom",rotate:{x:0,y:0,z:0},scale:1,container:document.documentElement,desktop:!0,mobile:!0,reset:!1,useDelay:"always",viewFactor:0,viewOffset:{top:0,right:0,bottom:0,left:0},afterReset:function(){},afterReveal:function(){},beforeReset:function(){},beforeReveal:function(){}},X={clean:function(){},destroy:function(){},reveal:function(){},sync:function(){},get noop(){return!0}},G=function(){var e=0;return function(){return e++}}(),J=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}(),K=Math.sign||function(e){return(e>0)-(e<0)||+e},Q=function(){var e=Date.now();return function(t){var n=Date.now();n-e>16?(e=n,t(n)):setTimeout(function(){return Q(t)},0)}}(),V=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||Q,Z="4.0.0-beta.23";return Y.isSupported=function(){return s()&&a()},Object.defineProperty(Y,"debug",{get:function(){return H||!1},set:function(e){"boolean"==typeof e&&(H=e)}}),Y}(); |
{ | ||
"name": "scrollreveal", | ||
"version": "4.0.0-beta.22", | ||
"version": "4.0.0-beta.23", | ||
"description": "Animate elements as they scroll into view", | ||
@@ -5,0 +5,0 @@ "homepage": "https://scrollrevealjs.org", |
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
118246
2636