scrollreveal
Advanced tools
Comparing version 3.0.3 to 3.0.4
@@ -17,3 +17,3 @@ | ||
___/ / /__/ / / /_/ / / / _, _/ __/ |/ / __/ /_/ / / | ||
/____/\___/_/ \____/_/_/_/ |_|\___/|___/\___/\__,_/_/ v3.0.3 | ||
/____/\___/_/ \____/_/_/_/ |_|\___/|___/\___/\__,_/_/ v3.0.4 | ||
@@ -61,4 +61,4 @@ ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ | ||
return false; | ||
} else if ( !sr.tools.browserSupports('transform') ) { | ||
return console.warn('Your browser does not support CSS transform.'); | ||
} else if ( !sr.tools.isSupported('transform') || !sr.tools.isSupported('transition') ) { | ||
return console.warn('ScrollReveal is not supported in this browser.'); | ||
} | ||
@@ -77,3 +77,3 @@ | ||
ScrollReveal.prototype.reveal = function( selector, config, sync ){ | ||
ScrollReveal.prototype.reveal = function( selector, config, sync ) { | ||
var elements, container, elem, elemId; | ||
@@ -89,3 +89,3 @@ | ||
if ( !elements.length ) { | ||
console.warn( 'reveal(\'' + selector + '\') failed: no elements found.' ); | ||
console.warn('reveal(\'' + selector + '\') failed: no elements found.'); | ||
return sr; | ||
@@ -122,4 +122,4 @@ } | ||
sr.record( selector, config ); | ||
sr.init(); | ||
} | ||
sr.init(); | ||
return sr; | ||
@@ -173,8 +173,8 @@ }; | ||
elem.styles.transform.initial += ' -webkit-transform:'; | ||
elem.styles.transform.target += ' -webkit-transform:'; | ||
elem.styles.transform.initial = ' -webkit-transform:'; | ||
elem.styles.transform.target = ' -webkit-transform:'; | ||
generateTransform( elem.styles.transform ); | ||
elem.styles.transform.initial = 'transform:'; | ||
elem.styles.transform.target = 'transform:'; | ||
elem.styles.transform.initial += 'transform:'; | ||
elem.styles.transform.target += 'transform:'; | ||
generateTransform( elem.styles.transform ); | ||
@@ -230,3 +230,3 @@ | ||
} | ||
if ( !sr.initialized ){ | ||
if ( !sr.initialized ) { | ||
window.addEventListener( 'scroll', sr.handler ); | ||
@@ -272,3 +272,3 @@ window.addEventListener( 'resize', sr.handler ); | ||
} else if ( !visible && elem.config.reset && elem.revealed ){ | ||
} else if ( !visible && elem.config.reset && elem.revealed ) { | ||
elem.domEl.setAttribute( 'style', | ||
@@ -316,8 +316,8 @@ elem.styles.inline | ||
ScrollReveal.prototype.getContainerSize = function( container ){ | ||
ScrollReveal.prototype.getContainer = function( container ) { | ||
if ( !container ) { | ||
container = window.document.documentElement; | ||
} | ||
var w = container['clientWidth'] || 0; | ||
var h = container['clientHeight'] || 0; | ||
var w = container.clientWidth; | ||
var h = container.clientHeight; | ||
return { | ||
@@ -329,3 +329,3 @@ width: w, | ||
ScrollReveal.prototype.getScrolled = function( container ){ | ||
ScrollReveal.prototype.getScrolled = function( container ) { | ||
if ( !container ) { | ||
@@ -346,4 +346,6 @@ return { | ||
ScrollReveal.prototype.getOffset = function( domEl ) { | ||
var offsetTop = 0; | ||
var offsetLeft = 0; | ||
var offsetTop = 0; | ||
var offsetLeft = 0; | ||
var offsetHeight = domEl.offsetHeight; | ||
var offsetWidth = domEl.offsetWidth; | ||
@@ -360,19 +362,20 @@ do { | ||
return { | ||
top: offsetTop, | ||
left: offsetLeft | ||
top : offsetTop, | ||
left : offsetLeft, | ||
height : offsetHeight, | ||
width : offsetWidth | ||
}; | ||
}; | ||
ScrollReveal.prototype.isElemVisible = function( elem ){ | ||
ScrollReveal.prototype.isElemVisible = function( elem ) { | ||
var offset = sr.getOffset( elem.domEl ); | ||
var container = sr.getContainerSize( elem.config.container ); | ||
var container = sr.getContainer( elem.config.container ); | ||
var scrolled = sr.getScrolled( elem.config.container ); | ||
var vF = elem.config.viewFactor; | ||
var elemHeight = elem.domEl.offsetHeight; | ||
var elemWidth = elem.domEl.offsetWidth; | ||
var elemHeight = offset.height; | ||
var elemWidth = offset.width; | ||
var elemTop = offset.top; | ||
var elemBottom = elemTop + elemHeight; | ||
var elemLeft = offset.left; | ||
var elemBottom = elemTop + elemHeight; | ||
var elemRight = elemLeft + elemWidth; | ||
@@ -382,13 +385,12 @@ | ||
function confirmBounds(){ | ||
function confirmBounds() { | ||
var top = elemTop + elemHeight * vF; | ||
var left = elemLeft + elemWidth * vF; | ||
var bottom = elemBottom - elemHeight * vF; | ||
var left = elemLeft + elemWidth * vF; | ||
var right = elemRight - elemWidth * vF; | ||
var viewTop = scrolled.y + elem.config.viewOffset.top; | ||
var viewLeft = scrolled.x + elem.config.viewOffset.left; | ||
var viewBottom = scrolled.y - elem.config.viewOffset.bottom + container.height; | ||
var viewLeft = scrolled.x + elem.config.viewOffset.left; | ||
var viewRight = scrolled.x - elem.config.viewOffset.right + container.width; | ||
var viewRight = scrolled.x - elem.config.viewOffset.right + container.width; | ||
@@ -401,3 +403,3 @@ return ( top < viewBottom ) | ||
function isPositionFixed(){ | ||
function isPositionFixed() { | ||
return ( window.getComputedStyle( elem.domEl ).position === 'fixed' ); | ||
@@ -413,2 +415,3 @@ } | ||
}; | ||
sr.init(); | ||
} else { | ||
@@ -431,4 +434,4 @@ console.warn('sync() failed: no reveals found.'); | ||
Tools.prototype.forOwn = function( object, callback ) { | ||
if ( !this.isObject( object ) ){ | ||
throw new TypeError( 'Expected \'object\', but received \'' + typeof object + '\'.' ); | ||
if ( !this.isObject( object ) ) { | ||
throw new TypeError('Expected \'object\', but received \'' + typeof object + '\'.'); | ||
} else { | ||
@@ -465,3 +468,3 @@ for ( var property in object ) { | ||
Tools.prototype.browserSupports = function( feature ) { | ||
Tools.prototype.isSupported = function( feature ) { | ||
var sensor = document.createElement('sensor'); | ||
@@ -471,3 +474,3 @@ var cssPrefix = 'Webkit,Moz,O,'.split(','); | ||
for ( var i = 0; i < tests.length; i++ ){ | ||
for ( var i = 0; i < tests.length; i++ ) { | ||
if ( !sensor.style[ tests[ i ] ] === '' ) { | ||
@@ -480,3 +483,3 @@ return false; | ||
function Tools(){}; | ||
function Tools() {}; | ||
return Tools; | ||
@@ -486,5 +489,5 @@ | ||
var _requestAnimationFrame = this.requestAnimationFrame || | ||
this.webkitRequestAnimationFrame || | ||
this.mozRequestAnimationFrame; | ||
var _requestAnimationFrame = window.requestAnimationFrame || | ||
window.webkitRequestAnimationFrame || | ||
window.mozRequestAnimationFrame; | ||
@@ -491,0 +494,0 @@ }).call( this ); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e(require,exports,module):t.ScrollReveal=e()}(this,function(t,e,n){return function(){var t,e,n;this.ScrollReveal=function(){function o(n){return window==this?new o(n):(e=this,e.tools=new t,e.tools.extend(e.defaults,n||{}),e.tools.isMobile()&&!e.defaults.mobile?!1:e.tools.browserSupports("transform")?(e.store={elements:{},containers:[]},e.history=[],e.counter=0,e.blocked=!1,e.initialized=!1,e):console.warn("Your browser does not support CSS transform."))}return o.prototype.defaults={origin:"bottom",distance:"20px",duration:500,delay:0,rotate:{x:0,y:0,z:0},opacity:0,scale:.9,easing:"cubic-bezier( 0.6, 0.2, 0.1, 1 )",container:null,mobile:!0,reset:!1,useDelay:"always",viewFactor:.2,viewOffset:{top:0,right:0,bottom:0,left:0},afterReveal:function(t){},afterReset:function(t){}},o.prototype.reveal=function(t,n,o){var i,r,s,a;if(r=n&&n.container?n.container:window.document.documentElement,i=Array.prototype.slice.call(r.querySelectorAll(t)),!i.length)return console.warn("reveal('"+t+"') failed: no elements found."),e;for(var l=0;l<i.length;l++)s={},a=i[l].getAttribute("data-sr-id"),a?s=e.store.elements[a]:(s={id:++e.counter,domEl:i[l],seen:!1,revealed:!1},s.domEl.setAttribute("data-sr-id",s.id)),e.configure(s,n||{}),e.style(s),e.updateStore(s),s.revealed||s.domEl.setAttribute("style",s.styles.inline+s.styles.transform.initial);return o||e.record(t,n),e.init(),e},o.prototype.configure=function(t,n){t.config?t.config=e.tools.extendClone(t.config,n):t.config=e.tools.extendClone(e.defaults,n),"top"===t.config.origin||"bottom"===t.config.origin?t.config.axis="Y":t.config.axis="X",("top"===t.config.origin||"left"===t.config.origin)&&(t.config.distance="-"+t.config.distance)},o.prototype.style=function(t){function e(e){parseInt(n.distance)&&(e.initial+=" translate"+n.axis+"("+n.distance+")",e.target+=" translate"+n.axis+"(0)"),n.scale&&(e.initial+=" scale("+n.scale+")",e.target+=" scale(1)"),n.rotate.x&&(e.initial+=" rotateX("+n.rotate.x+"deg)",e.target+=" rotateX(0)"),n.rotate.y&&(e.initial+=" rotateY("+n.rotate.y+"deg)",e.target+=" rotateY(0)"),n.rotate.z&&(e.initial+=" rotateZ("+n.rotate.z+"deg)",e.target+=" rotateZ(0)"),e.initial+="; opacity: "+n.opacity+";",e.target+="; opacity: "+t.styles.computed.opacity+";"}var n=t.config,o=window.getComputedStyle(t.domEl);t.styles||(t.styles={transition:{},transform:{},computed:{}},t.styles.inline=t.domEl.getAttribute("style")||"",t.styles.inline+="; visibility: visible; ",t.styles.computed.opacity=o.opacity,o.transition&&"all 0s ease 0s"!=o.transition?t.styles.computed.transition=o.transition+", ":t.styles.computed.transition=""),t.styles.transition.instant="-webkit-transition: "+t.styles.computed.transition+"-webkit-transform "+n.duration/1e3+"s "+n.easing+" 0s, opacity "+n.duration/1e3+"s "+n.easing+" 0s; transition: "+t.styles.computed.transition+"transform "+n.duration/1e3+"s "+n.easing+" 0s, opacity "+n.duration/1e3+"s "+n.easing+" 0s; ",t.styles.transition.delayed="-webkit-transition: "+t.styles.computed.transition+"-webkit-transform "+n.duration/1e3+"s "+n.easing+" "+n.delay/1e3+"s, opacity "+n.duration/1e3+"s "+n.easing+" "+n.delay/1e3+"s; transition: "+t.styles.computed.transition+"transform "+n.duration/1e3+"s "+n.easing+" "+n.delay/1e3+"s, opacity "+n.duration/1e3+"s "+n.easing+" "+n.delay/1e3+"s; ",t.styles.transform.initial+=" -webkit-transform:",t.styles.transform.target+=" -webkit-transform:",e(t.styles.transform),t.styles.transform.initial="transform:",t.styles.transform.target="transform:",e(t.styles.transform)},o.prototype.updateStore=function(t){var n=t.config.container;n&&-1==e.store.containers.indexOf(n)&&e.store.containers.push(t.config.container),e.store.elements[t.id]=t},o.prototype.record=function(t,n){var o={selector:t,config:n};e.history.push(o)},o.prototype.init=function(){e.animate();for(var t=e.store.containers.length-1;t>=0;t--)e.store.containers[t].addEventListener("scroll",e.handler),e.store.containers[t].addEventListener("resize",e.handler);return e.initialized||(window.addEventListener("scroll",e.handler),window.addEventListener("resize",e.handler),e.initialized=!0),e},o.prototype.handler=function(){e.blocked||(e.blocked=!0,n(e.animate))},o.prototype.animate=function(){function t(t,e){var n=0,o=0,i="after";switch(t){case"reveal":o=e.config.duration+e.config.delay,i+="Reveal";break;case"reset":o=e.config.duration,i+="Reset"}return e.timer&&(n=Math.abs(e.timer.started-new Date),window.clearTimeout(e.timer.clock)),e.timer={started:new Date},e.timer.clock=window.setTimeout(function(){e.config[i](e.domEl),e.timer=null},o-n),"reveal"===t?e.revealed=!0:e.revealed=!1}var n,o;e.tools.forOwn(e.store.elements,function(i){n=e.store.elements[i],o=e.isElemVisible(n),o&&!n.revealed?("always"===n.config.useDelay||"onload"===n.config.useDelay&&!e.initialized||"once"===n.config.useDelay&&!n.seen?n.domEl.setAttribute("style",n.styles.inline+n.styles.transform.target+n.styles.transition.delayed):n.domEl.setAttribute("style",n.styles.inline+n.styles.transform.target+n.styles.transition.instant),n.seen=!0,t("reveal",n)):!o&&n.config.reset&&n.revealed&&(n.domEl.setAttribute("style",n.styles.inline+n.styles.transform.initial+n.styles.transition.instant),t("reset",n))}),e.blocked=!1},o.prototype.getContainerSize=function(t){t||(t=window.document.documentElement);var e=t.clientWidth||0,n=t.clientHeight||0;return{width:e,height:n}},o.prototype.getScrolled=function(t){if(t){var n=e.getOffset(t);return{x:t.scrollLeft+n.left,y:t.scrollTop+n.top}}return{x:window.pageXOffset,y:window.pageYOffset}},o.prototype.getOffset=function(t){var e=0,n=0;do isNaN(t.offsetTop)||(e+=t.offsetTop),isNaN(t.offsetLeft)||(n+=t.offsetLeft);while(t=t.offsetParent);return{top:e,left:n}},o.prototype.isElemVisible=function(t){function n(){var e=f+l*a,n=d-l*a,o=u+c*a,i=y-c*a,p=s.y+t.config.viewOffset.top,g=s.y-t.config.viewOffset.bottom+r.height,m=s.x+t.config.viewOffset.left,w=s.x-t.config.viewOffset.right+r.width;return g>e&&n>p&&o>m&&w>i}function o(){return"fixed"===window.getComputedStyle(t.domEl).position}var i=e.getOffset(t.domEl),r=e.getContainerSize(t.config.container),s=e.getScrolled(t.config.container),a=t.config.viewFactor,l=t.domEl.offsetHeight,c=t.domEl.offsetWidth,f=i.top,d=f+l,u=i.left,y=u+c;return n()||o()},o.prototype.sync=function(){if(e.history.length)for(var t=0;t<e.history.length;t++){var n=e.history[t];e.reveal(n.selector,n.config,!0)}else console.warn("sync() failed: no reveals found.");return e},o}();var t=function(){function t(){}return t.prototype.isObject=function(t){return null!==t&&"object"==typeof t&&t.constructor==Object},t.prototype.forOwn=function(t,e){if(!this.isObject(t))throw new TypeError("Expected 'object', but received '"+typeof t+"'.");for(var n in t)t.hasOwnProperty(n)&&e(n)},t.prototype.extend=function(t,e){return this.forOwn(e,function(n){this.isObject(e[n])?(t[n]&&this.isObject(t[n])||(t[n]={}),this.extend(t[n],e[n])):t[n]=e[n]}.bind(this)),t},t.prototype.extendClone=function(t,e){return this.extend(this.extend({},t),e)},t.prototype.isMobile=function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},t.prototype.browserSupports=function(t){for(var e=document.createElement("sensor"),n="Webkit,Moz,O,".split(","),o=(t+n.join(t+",")).split(","),i=0;i<o.length;i++)if(""===!e.style[o[i]])return!1;return!0},t}(),n=this.requestAnimationFrame||this.webkitRequestAnimationFrame||this.mozRequestAnimationFrame}.call(this),ScrollReveal}); | ||
!function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e(require,exports,module):t.ScrollReveal=e()}(this,function(t,e,i){return function(){var t,e,i;this.ScrollReveal=function(){function n(i){return window==this?new n(i):(e=this,e.tools=new t,e.tools.extend(e.defaults,i||{}),e.tools.isMobile()&&!e.defaults.mobile?!1:e.tools.isSupported("transform")&&e.tools.isSupported("transition")?(e.store={elements:{},containers:[]},e.history=[],e.counter=0,e.blocked=!1,e.initialized=!1,e):console.warn("ScrollReveal is not supported in this browser."))}return n.prototype.defaults={origin:"bottom",distance:"20px",duration:500,delay:0,rotate:{x:0,y:0,z:0},opacity:0,scale:.9,easing:"cubic-bezier( 0.6, 0.2, 0.1, 1 )",container:null,mobile:!0,reset:!1,useDelay:"always",viewFactor:.2,viewOffset:{top:0,right:0,bottom:0,left:0},afterReveal:function(t){},afterReset:function(t){}},n.prototype.reveal=function(t,i,n){var o,r,s,a;if(r=i&&i.container?i.container:window.document.documentElement,o=Array.prototype.slice.call(r.querySelectorAll(t)),!o.length)return console.warn("reveal('"+t+"') failed: no elements found."),e;for(var l=0;l<o.length;l++)s={},a=o[l].getAttribute("data-sr-id"),a?s=e.store.elements[a]:(s={id:++e.counter,domEl:o[l],seen:!1,revealed:!1},s.domEl.setAttribute("data-sr-id",s.id)),e.configure(s,i||{}),e.style(s),e.updateStore(s),s.revealed||s.domEl.setAttribute("style",s.styles.inline+s.styles.transform.initial);return n||(e.record(t,i),e.init()),e},n.prototype.configure=function(t,i){t.config?t.config=e.tools.extendClone(t.config,i):t.config=e.tools.extendClone(e.defaults,i),"top"===t.config.origin||"bottom"===t.config.origin?t.config.axis="Y":t.config.axis="X",("top"===t.config.origin||"left"===t.config.origin)&&(t.config.distance="-"+t.config.distance)},n.prototype.style=function(t){function e(e){parseInt(i.distance)&&(e.initial+=" translate"+i.axis+"("+i.distance+")",e.target+=" translate"+i.axis+"(0)"),i.scale&&(e.initial+=" scale("+i.scale+")",e.target+=" scale(1)"),i.rotate.x&&(e.initial+=" rotateX("+i.rotate.x+"deg)",e.target+=" rotateX(0)"),i.rotate.y&&(e.initial+=" rotateY("+i.rotate.y+"deg)",e.target+=" rotateY(0)"),i.rotate.z&&(e.initial+=" rotateZ("+i.rotate.z+"deg)",e.target+=" rotateZ(0)"),e.initial+="; opacity: "+i.opacity+";",e.target+="; opacity: "+t.styles.computed.opacity+";"}var i=t.config,n=window.getComputedStyle(t.domEl);t.styles||(t.styles={transition:{},transform:{},computed:{}},t.styles.inline=t.domEl.getAttribute("style")||"",t.styles.inline+="; visibility: visible; ",t.styles.computed.opacity=n.opacity,n.transition&&"all 0s ease 0s"!=n.transition?t.styles.computed.transition=n.transition+", ":t.styles.computed.transition=""),t.styles.transition.instant="-webkit-transition: "+t.styles.computed.transition+"-webkit-transform "+i.duration/1e3+"s "+i.easing+" 0s, opacity "+i.duration/1e3+"s "+i.easing+" 0s; transition: "+t.styles.computed.transition+"transform "+i.duration/1e3+"s "+i.easing+" 0s, opacity "+i.duration/1e3+"s "+i.easing+" 0s; ",t.styles.transition.delayed="-webkit-transition: "+t.styles.computed.transition+"-webkit-transform "+i.duration/1e3+"s "+i.easing+" "+i.delay/1e3+"s, opacity "+i.duration/1e3+"s "+i.easing+" "+i.delay/1e3+"s; transition: "+t.styles.computed.transition+"transform "+i.duration/1e3+"s "+i.easing+" "+i.delay/1e3+"s, opacity "+i.duration/1e3+"s "+i.easing+" "+i.delay/1e3+"s; ",t.styles.transform.initial=" -webkit-transform:",t.styles.transform.target=" -webkit-transform:",e(t.styles.transform),t.styles.transform.initial+="transform:",t.styles.transform.target+="transform:",e(t.styles.transform)},n.prototype.updateStore=function(t){var i=t.config.container;i&&-1==e.store.containers.indexOf(i)&&e.store.containers.push(t.config.container),e.store.elements[t.id]=t},n.prototype.record=function(t,i){var n={selector:t,config:i};e.history.push(n)},n.prototype.init=function(){e.animate();for(var t=e.store.containers.length-1;t>=0;t--)e.store.containers[t].addEventListener("scroll",e.handler),e.store.containers[t].addEventListener("resize",e.handler);return e.initialized||(window.addEventListener("scroll",e.handler),window.addEventListener("resize",e.handler),e.initialized=!0),e},n.prototype.handler=function(){e.blocked||(e.blocked=!0,i(e.animate))},n.prototype.animate=function(){function t(t,e){var i=0,n=0,o="after";switch(t){case"reveal":n=e.config.duration+e.config.delay,o+="Reveal";break;case"reset":n=e.config.duration,o+="Reset"}return e.timer&&(i=Math.abs(e.timer.started-new Date),window.clearTimeout(e.timer.clock)),e.timer={started:new Date},e.timer.clock=window.setTimeout(function(){e.config[o](e.domEl),e.timer=null},n-i),"reveal"===t?e.revealed=!0:e.revealed=!1}var i,n;e.tools.forOwn(e.store.elements,function(o){i=e.store.elements[o],n=e.isElemVisible(i),n&&!i.revealed?("always"===i.config.useDelay||"onload"===i.config.useDelay&&!e.initialized||"once"===i.config.useDelay&&!i.seen?i.domEl.setAttribute("style",i.styles.inline+i.styles.transform.target+i.styles.transition.delayed):i.domEl.setAttribute("style",i.styles.inline+i.styles.transform.target+i.styles.transition.instant),i.seen=!0,t("reveal",i)):!n&&i.config.reset&&i.revealed&&(i.domEl.setAttribute("style",i.styles.inline+i.styles.transform.initial+i.styles.transition.instant),t("reset",i))}),e.blocked=!1},n.prototype.getContainer=function(t){t||(t=window.document.documentElement);var e=t.clientWidth,i=t.clientHeight;return{width:e,height:i}},n.prototype.getScrolled=function(t){if(t){var i=e.getOffset(t);return{x:t.scrollLeft+i.left,y:t.scrollTop+i.top}}return{x:window.pageXOffset,y:window.pageYOffset}},n.prototype.getOffset=function(t){var e=0,i=0,n=t.offsetHeight,o=t.offsetWidth;do isNaN(t.offsetTop)||(e+=t.offsetTop),isNaN(t.offsetLeft)||(i+=t.offsetLeft);while(t=t.offsetParent);return{top:e,left:i,height:n,width:o}},n.prototype.isElemVisible=function(t){function i(){var e=f+l*a,i=d+c*a,n=u-l*a,o=y-c*a,p=s.y+t.config.viewOffset.top,g=s.x+t.config.viewOffset.left,m=s.y-t.config.viewOffset.bottom+r.height,w=s.x-t.config.viewOffset.right+r.width;return m>e&&n>p&&i>g&&w>o}function n(){return"fixed"===window.getComputedStyle(t.domEl).position}var o=e.getOffset(t.domEl),r=e.getContainer(t.config.container),s=e.getScrolled(t.config.container),a=t.config.viewFactor,l=o.height,c=o.width,f=o.top,d=o.left,u=f+l,y=d+c;return i()||n()},n.prototype.sync=function(){if(e.history.length){for(var t=0;t<e.history.length;t++){var i=e.history[t];e.reveal(i.selector,i.config,!0)}e.init()}else console.warn("sync() failed: no reveals found.");return e},n}();var t=function(){function t(){}return t.prototype.isObject=function(t){return null!==t&&"object"==typeof t&&t.constructor==Object},t.prototype.forOwn=function(t,e){if(!this.isObject(t))throw new TypeError("Expected 'object', but received '"+typeof t+"'.");for(var i in t)t.hasOwnProperty(i)&&e(i)},t.prototype.extend=function(t,e){return this.forOwn(e,function(i){this.isObject(e[i])?(t[i]&&this.isObject(t[i])||(t[i]={}),this.extend(t[i],e[i])):t[i]=e[i]}.bind(this)),t},t.prototype.extendClone=function(t,e){return this.extend(this.extend({},t),e)},t.prototype.isMobile=function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},t.prototype.isSupported=function(t){for(var e=document.createElement("sensor"),i="Webkit,Moz,O,".split(","),n=(t+i.join(t+",")).split(","),o=0;o<n.length;o++)if(""===!e.style[n[o]])return!1;return!0},t}(),i=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame}.call(this),ScrollReveal}); |
{ | ||
"name" : "scrollreveal", | ||
"version" : "3.0.3", | ||
"version" : "3.0.4", | ||
"description" : "Easy scroll animations for web and mobile browsers.", | ||
@@ -5,0 +5,0 @@ "homepage" : "https://scrollrevealjs.org", |
@@ -7,3 +7,4 @@ [![ScrollReveal — Easy scroll animations for web and mobile browsers.](https://scrollrevealjs.org/assets/scrollreveal-repo-header.png)](https://scrollrevealjs.org) | ||
[![ScrollReveal version](http://img.shields.io/badge/scrollreveal.js-v3.0.3-1a2434.svg)](https://scrollrevealjs.org) [![License](http://img.shields.io/badge/License-MIT-1a2434.svg)](http://opensource.org/licenses/MIT) | ||
[![NPM version][npm-image]][npm-url] | ||
[![NPM downloads][downloads-image]][downloads-url] | ||
@@ -20,6 +21,6 @@ - 2.9KB minified and Gzipped | ||
The simplest method is to copy paste this snippet just before your closing `</body>` tag (thanks to jsDelivr) | ||
The simplest method is to copy paste this snippet just before your closing `</body>` tag. | ||
```html | ||
<script src="https://cdn.jsdelivr.net/scrollreveal.js/3.0.3/scrollreveal.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/scrollreveal.js/3.0.4/scrollreveal.min.js"></script> | ||
``` | ||
@@ -69,3 +70,3 @@ | ||
// Customizing a reveal set | ||
sr.reveal( '.foo', { wait: 200 } ); | ||
sr.reveal( '.foo', { duration: 200 } ); | ||
``` | ||
@@ -344,1 +345,6 @@ | ||
ScrollReveal was inspired by the talented [Manoela Ilic](https://twitter.com/crnacura) and her [cbpScroller.js](http://tympanus.net/codrops/2013/07/18/on-scroll-effect-layout/). | ||
[npm-image]: https://img.shields.io/npm/v/scrollreveal.svg?style=flat | ||
[npm-url]: https://npmjs.org/package/scrollreveal | ||
[downloads-image]: https://img.shields.io/npm/dm/scrollreveal.svg?style=flat | ||
[downloads-url]: https://npmjs.org/package/scrollreveal |
@@ -6,3 +6,3 @@ /* | ||
___/ / /__/ / / /_/ / / / _, _/ __/ |/ / __/ /_/ / / | ||
/____/\___/_/ \____/_/_/_/ |_|\___/|___/\___/\__,_/_/ v3.0.3 | ||
/____/\___/_/ \____/_/_/_/ |_|\___/|___/\___/\__,_/_/ v3.0.4 | ||
@@ -50,4 +50,4 @@ ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ | ||
return false; | ||
} else if ( !sr.tools.browserSupports('transform') ) { | ||
return console.warn('Your browser does not support CSS transform.'); | ||
} else if ( !sr.tools.isSupported('transform') || !sr.tools.isSupported('transition') ) { | ||
return console.warn('ScrollReveal is not supported in this browser.'); | ||
} | ||
@@ -66,3 +66,3 @@ | ||
ScrollReveal.prototype.reveal = function( selector, config, sync ){ | ||
ScrollReveal.prototype.reveal = function( selector, config, sync ) { | ||
var elements, container, elem, elemId; | ||
@@ -78,3 +78,3 @@ | ||
if ( !elements.length ) { | ||
console.warn( 'reveal(\'' + selector + '\') failed: no elements found.' ); | ||
console.warn('reveal(\'' + selector + '\') failed: no elements found.'); | ||
return sr; | ||
@@ -111,4 +111,4 @@ } | ||
sr.record( selector, config ); | ||
sr.init(); | ||
} | ||
sr.init(); | ||
return sr; | ||
@@ -162,8 +162,8 @@ }; | ||
elem.styles.transform.initial += ' -webkit-transform:'; | ||
elem.styles.transform.target += ' -webkit-transform:'; | ||
elem.styles.transform.initial = ' -webkit-transform:'; | ||
elem.styles.transform.target = ' -webkit-transform:'; | ||
generateTransform( elem.styles.transform ); | ||
elem.styles.transform.initial = 'transform:'; | ||
elem.styles.transform.target = 'transform:'; | ||
elem.styles.transform.initial += 'transform:'; | ||
elem.styles.transform.target += 'transform:'; | ||
generateTransform( elem.styles.transform ); | ||
@@ -219,3 +219,3 @@ | ||
} | ||
if ( !sr.initialized ){ | ||
if ( !sr.initialized ) { | ||
window.addEventListener( 'scroll', sr.handler ); | ||
@@ -261,3 +261,3 @@ window.addEventListener( 'resize', sr.handler ); | ||
} else if ( !visible && elem.config.reset && elem.revealed ){ | ||
} else if ( !visible && elem.config.reset && elem.revealed ) { | ||
elem.domEl.setAttribute( 'style', | ||
@@ -305,8 +305,8 @@ elem.styles.inline | ||
ScrollReveal.prototype.getContainerSize = function( container ){ | ||
ScrollReveal.prototype.getContainer = function( container ) { | ||
if ( !container ) { | ||
container = window.document.documentElement; | ||
} | ||
var w = container['clientWidth'] || 0; | ||
var h = container['clientHeight'] || 0; | ||
var w = container.clientWidth; | ||
var h = container.clientHeight; | ||
return { | ||
@@ -318,3 +318,3 @@ width: w, | ||
ScrollReveal.prototype.getScrolled = function( container ){ | ||
ScrollReveal.prototype.getScrolled = function( container ) { | ||
if ( !container ) { | ||
@@ -335,4 +335,6 @@ return { | ||
ScrollReveal.prototype.getOffset = function( domEl ) { | ||
var offsetTop = 0; | ||
var offsetLeft = 0; | ||
var offsetTop = 0; | ||
var offsetLeft = 0; | ||
var offsetHeight = domEl.offsetHeight; | ||
var offsetWidth = domEl.offsetWidth; | ||
@@ -349,19 +351,20 @@ do { | ||
return { | ||
top: offsetTop, | ||
left: offsetLeft | ||
top : offsetTop, | ||
left : offsetLeft, | ||
height : offsetHeight, | ||
width : offsetWidth | ||
}; | ||
}; | ||
ScrollReveal.prototype.isElemVisible = function( elem ){ | ||
ScrollReveal.prototype.isElemVisible = function( elem ) { | ||
var offset = sr.getOffset( elem.domEl ); | ||
var container = sr.getContainerSize( elem.config.container ); | ||
var container = sr.getContainer( elem.config.container ); | ||
var scrolled = sr.getScrolled( elem.config.container ); | ||
var vF = elem.config.viewFactor; | ||
var elemHeight = elem.domEl.offsetHeight; | ||
var elemWidth = elem.domEl.offsetWidth; | ||
var elemHeight = offset.height; | ||
var elemWidth = offset.width; | ||
var elemTop = offset.top; | ||
var elemBottom = elemTop + elemHeight; | ||
var elemLeft = offset.left; | ||
var elemBottom = elemTop + elemHeight; | ||
var elemRight = elemLeft + elemWidth; | ||
@@ -371,13 +374,12 @@ | ||
function confirmBounds(){ | ||
function confirmBounds() { | ||
var top = elemTop + elemHeight * vF; | ||
var left = elemLeft + elemWidth * vF; | ||
var bottom = elemBottom - elemHeight * vF; | ||
var left = elemLeft + elemWidth * vF; | ||
var right = elemRight - elemWidth * vF; | ||
var viewTop = scrolled.y + elem.config.viewOffset.top; | ||
var viewLeft = scrolled.x + elem.config.viewOffset.left; | ||
var viewBottom = scrolled.y - elem.config.viewOffset.bottom + container.height; | ||
var viewLeft = scrolled.x + elem.config.viewOffset.left; | ||
var viewRight = scrolled.x - elem.config.viewOffset.right + container.width; | ||
var viewRight = scrolled.x - elem.config.viewOffset.right + container.width; | ||
@@ -390,3 +392,3 @@ return ( top < viewBottom ) | ||
function isPositionFixed(){ | ||
function isPositionFixed() { | ||
return ( window.getComputedStyle( elem.domEl ).position === 'fixed' ); | ||
@@ -402,2 +404,3 @@ } | ||
}; | ||
sr.init(); | ||
} else { | ||
@@ -420,4 +423,4 @@ console.warn('sync() failed: no reveals found.'); | ||
Tools.prototype.forOwn = function( object, callback ) { | ||
if ( !this.isObject( object ) ){ | ||
throw new TypeError( 'Expected \'object\', but received \'' + typeof object + '\'.' ); | ||
if ( !this.isObject( object ) ) { | ||
throw new TypeError('Expected \'object\', but received \'' + typeof object + '\'.'); | ||
} else { | ||
@@ -454,3 +457,3 @@ for ( var property in object ) { | ||
Tools.prototype.browserSupports = function( feature ) { | ||
Tools.prototype.isSupported = function( feature ) { | ||
var sensor = document.createElement('sensor'); | ||
@@ -460,3 +463,3 @@ var cssPrefix = 'Webkit,Moz,O,'.split(','); | ||
for ( var i = 0; i < tests.length; i++ ){ | ||
for ( var i = 0; i < tests.length; i++ ) { | ||
if ( !sensor.style[ tests[ i ] ] === '' ) { | ||
@@ -469,3 +472,3 @@ return false; | ||
function Tools(){}; | ||
function Tools() {}; | ||
return Tools; | ||
@@ -475,6 +478,6 @@ | ||
var _requestAnimationFrame = this.requestAnimationFrame || | ||
this.webkitRequestAnimationFrame || | ||
this.mozRequestAnimationFrame; | ||
var _requestAnimationFrame = window.requestAnimationFrame || | ||
window.webkitRequestAnimationFrame || | ||
window.mozRequestAnimationFrame; | ||
}).call( this ); |
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
54504
869
347