scam/js/stellar.js

18 lines
15 KiB
JavaScript
Raw Normal View History

2019-02-18 08:43:07 +00:00
/*! Stellar.js v0.6.2 | Copyright 2013, Mark Dalgleish | http://markdalgleish.com/projects/stellar.js | http://markdalgleish.mit-license.org */
(function(e,t,n,r){function d(t,n){this.element=t,this.options=e.extend({},s,n),this._defaults=s,this._name=i,this.init()}var i="stellar",s={scrollProperty:"scroll",positionProperty:"position",horizontalScrolling:!0,verticalScrolling:!0,horizontalOffset:0,verticalOffset:0,responsive:!1,parallaxBackgrounds:!0,parallaxElements:!0,hideDistantElements:!0,hideElement:function(e){e.hide()},showElement:function(e){e.show()}},o={scroll:{getLeft:function(e){return e.scrollLeft()},setLeft:function(e,t){e.scrollLeft(t)},getTop:function(e){return e.scrollTop()},setTop:function(e,t){e.scrollTop(t)}},position:{getLeft:function(e){return parseInt(e.css("left"),10)*-1},getTop:function(e){return parseInt(e.css("top"),10)*-1}},margin:{getLeft:function(e){return parseInt(e.css("margin-left"),10)*-1},getTop:function(e){return parseInt(e.css("margin-top"),10)*-1}},transform:{getLeft:function(e){var t=getComputedStyle(e[0])[f];return t!=="none"?parseInt(t.match(/(-?[0-9]+)/g)[4],10)*-1:0},getTop:function(e){var t=getComputedStyle(e[0])[f];return t!=="none"?parseInt(t.match(/(-?[0-9]+)/g)[5],10)*-1:0}}},u={position:{setLeft:function(e,t){e.css("left",t)},setTop:function(e,t){e.css("top",t)}},transform:{setPosition:function(e,t,n,r,i){e[0].style[f]="translate3d("+(t-n)+"px, "+(r-i)+"px, 0)"}}},a=function(){var t=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,n=e("script")[0].style,r="",i;for(i in n)if(t.test(i)){r=i.match(t)[0];break}return"WebkitOpacity"in n&&(r="Webkit"),"KhtmlOpacity"in n&&(r="Khtml"),function(e){return r+(r.length>0?e.charAt(0).toUpperCase()+e.slice(1):e)}}(),f=a("transform"),l=e("<div />",{style:"background:#fff"}).css("background-position-x")!==r,c=l?function(e,t,n){e.css({"background-position-x":t,"background-position-y":n})}:function(e,t,n){e.css("background-position",t+" "+n)},h=l?function(e){return[e.css("background-position-x"),e.css("background-position-y")]}:function(e){return e.css("background-position").split(" ")},p=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)};d.prototype={init:function(){this.options.name=i+"_"+Math.floor(Math.random()*1e9),this._defineElements(),this._defineGetters(),this._defineSetters(),this._handleWindowLoadAndResize(),this._detectViewport(),this.refresh({firstLoad:!0}),this.options.scrollProperty==="scroll"?this._handleScrollEvent():this._startAnimationLoop()},_defineElements:function(){this.element===n.body&&(this.element=t),this.$scrollElement=e(this.element),this.$element=this.element===t?e("body"):this.$scrollElement,this.$viewportElement=this.options.viewportElement!==r?e(this.options.viewportElement):this.$scrollElement[0]===t||this.options.scrollProperty==="scroll"?this.$scrollElement:this.$scrollElement.parent()},_defineGetters:function(){var e=this,t=o[e.options.scrollProperty];this._getScrollLeft=function(){return t.getLeft(e.$scrollElement)},this._getScrollTop=function(){return t.getTop(e.$scrollElement)}},_defineSetters:function(){var t=this,n=o[t.options.scrollProperty],r=u[t.options.positionProperty],i=n.setLeft,s=n.setTop;this._setScrollLeft=typeof i=="function"?function(e){i(t.$scrollElement,e)}:e.noop,this._setScrollTop=typeof s=="function"?function(e){s(t.$scrollElement,e)}:e.noop,this._setPosition=r.setPosition||function(e,n,i,s,o){t.options.horizontalScrolling&&r.setLeft(e,n,i),t.options.verticalScrolling&&r.setTop(e,s,o)}},_handleWindowLoadAndResize:function(){var n=this,r=e(t);n.options.responsive&&r.bind("load."+this.name,function(){n.refresh()}),r.bind("resize."+this.name,function(){n._detectViewport(),n.options.responsive&&n.refresh()})},refresh:function(n){var r=this,i=r._getScrollLeft(),s=r._getScrollTop();(!n||!n.firstLoad)&&this._reset(),this._setScrollLeft(0),this._setScrollTop(0),this._setOffsets(),this._findParticles(),this._findBackgrounds(),n&&n.firstLoad&&/WebKit/.test(navigator.userAgent)&&e(t).load(function(){var e=r._getScrollLeft(),t=r._getScrollTop();r._setScrollLeft(e+1),r._setScrollTop(t+1),r._setScrollLeft(e),r._setScrollTop(t)}
/**!
* @author odahcam
* @see The boilerplate used here was https://github.com/odahcam/jQueryPlugin-Boilerplate
* @external https://github.com/odahcam/jquery.parallax/
*/
/**
* @param {object} $
* @param {object} window
* @param {object} document
* @param {undefined} undefined
* @return
*/
(function(d,f,g,b){if(!d){console.error("jQuery não encontrado, seu plugin jQuery não irá funcionar.");return false}(function(){var k=0,l=["ms","moz","webkit","o"];for(var j=0;j<l.length&&!f.requestAnimationFrame;++j){f.requestAnimationFrame=f[l[j]+"RequestAnimationFrame"];f.cancelAnimationFrame=f[l[j]+"CancelAnimationFrame"]||f[l[j]+"CancelRequestAnimationFrame"]}if(!f.requestAnimationFrame){f.requestAnimationFrame=function(q,n){var m=new Date().getTime();var o=Math.max(0,16-(m-k));var p=f.setTimeout(function(){q(m+o)},o);k=m+o;return p}}if(!f.cancelAnimationFrame){f.cancelAnimationFrame=function(m){clearTimeout(m)}}})();var e="parallax",c={on:"scroll",listenTo:f,sceneMode:false},a=d(f),i=0;function h(k,j){this._name=e;this._instance_id=++i;this.el=k;this.$el=d(k);this.settings=d.extend(false,{},c,j,this.$el.data());this.$triggerOrigin=d(this.settings.listenTo);this.init()}d.extend(h.prototype,{init:function(){var j=this;this.$triggerOrigin.on(j.settings.on+"."+j._name,function(){j.parallaxTranslate()});j.parallaxTranslate()},parallaxTranslate:function(){var j=this;if(j.inScreen()){f.requestAnimationFrame(function(){var k=a.scrollTop()-j.$el.offset().top;j.$el.css("transform","translateY("+k/2+"px)")})}console.groupEnd()},destroy:function(){this.$el.removeData();d(this.settings.listenTo).off("."+e)},somePublicMethod:function(k,j){privateMethod.call(this)},inScreen:function(l){var o;if(typeof l!=="boolean"&&l!==b){o=d(l);l=arguments[1]||false}else{o=this.$el;l=l||false}var k=a.scrollTop(),n=k+a.height(),j=o.offset().top,m=j+o.height();if(l===true){return k<=j&&n>=m}return !(k>m||n<j)}});d.fn[e]=function(k){var j=arguments;if(k===b||typeof k==="object"){return this.each(function(){if(!d.data(this,"plugin_"+e)){d.data(this,"plugin_"+e,new h(this,k))}})}else{if(typeof k==="string"&&k!=="init"){return this.each(function(){var l=d.data(this,"plugin_"+e);if(l instanceof h&&typeof l[k]==="function"){l[k].apply(l,Array.prototype.slice.call(j,1))}})}}}})(window.jQuery||false,window,document);