Team:UT-Dallas/jquery.scrollmagic.min.js

From 2014.igem.org

Revision as of 17:13, 17 October 2014 by Mzerez (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

/* ScrollMagic v1.1.0 | (c) 2014 Jan Paepke (@janpaepke) | license & info: http://janpaepke.github.io/ScrollMagic */

!function(e,t){"use strict";var r=function(r){var i,s="ScrollMagic",a={container:t,vertical:!0,globalSceneOptions:{},loglevel:2,refreshInterval:100},l=this,c=e.extend({},a,r),u=[],g=!1,f=0,h="PAUSED",d=!0,p=0,v=!1,m=!0,w=function(){if(e.each(c,function(e){a.hasOwnProperty(e)||delete c[e]}),c.container=e(c.container).first(),0===c.container.length)throw s+" init failed.";d=!e.contains(document,c.container.get(0)),p=c.vertical?c.container.height():c.container.width(),c.container.on("scroll resize",F);try{TweenLite.ticker.addEventListener("tick",y),v=!0}catch(r){c.container.on("scroll resize",y),v=!1}c.refreshInterval=parseInt(c.refreshInterval),c.refreshInterval>0&&(i=t.setInterval(b,c.refreshInterval))},E=function(){return c.vertical?c.container.scrollTop():c.container.scrollLeft()},S=function(e){c.vertical?c.container.scrollTop(e):c.container.scrollLeft(e)},y=function(){if(g&&m){var t=e.isArray(g)?g:u.slice(0),r=f;f=l.scrollPos();var n=f-r;h=0===n?"PAUSED":n>0?"FORWARD":"REVERSE",0>n&&t.reverse(),e.each(t,function(e,t){t.update(!0)}),0===t.length&&c.loglevel>=3,g=!1}},F=function(e){"resize"==e.type&&(p=c.vertical?c.container.height():c.container.width()),g=!0},b=function(){d||p!=(c.vertical?c.container.height():c.container.width())&&c.container.trigger("resize"),e.each(u,function(e,t){t.refresh()})},T=function(e){if(e.length<=1)return e;var t=e.slice(0);return t.sort(function(e,t){return e.scrollOffset()>t.scrollOffset()?1:-1}),t};return this.addScene=function(t){return e.isArray(t)?e.each(t,function(e,t){l.addScene(t)}):t instanceof n&&(t.parent()!=l?t.addTo(l):e.inArray(t,u)<0&&(u.push(t),u=T(u),t.on("shift."+s+"_sort",function(){u=T(u)}),e.each(c.globalSceneOptions,function(e,r){t[e]&&t[e].call(t,r)}))),l},this.removeScene=function(t){if(e.isArray(t))e.each(t,function(e,t){l.removeScene(t)});else{var r=e.inArray(t,u);r>-1&&(t.off("shift."+s+"_sort"),u.splice(r,1),t.remove())}return l},this.updateScene=function(t,r){return e.isArray(t)?e.each(t,function(e,t){l.updateScene(t,r)}):r?t.update(!0):(e.isArray(g)||(g=[]),-1==e.inArray(t,g)&&g.push(t),g=T(g)),l},this.update=function(e){return F({type:"resize"}),e&&y(),l},this.scrollTo=function(t){if(t instanceof n)t.parent()===l?l.scrollTo(t.scrollOffset()):log(2,"scrollTo(): The supplied scene does not belong to this controller. Scroll cancelled.",t);else if("string"===e.type(t)||o(t)||t instanceof e){var r=e(t).first();if(r[0]){var i=r.offset();l.scrollTo(c.vertical?i.top:i.left)}else log(2,"scrollTo(): The supplied element could not be found. Scroll cancelled.",t)}else e.isFunction(t)?S=t:S.call(c.container[0],t);return l},this.scrollPos=function(t){return arguments.length?(e.isFunction(t)&&(E=t),l):E.call(l)},this.info=function(e){var t={size:p,vertical:c.vertical,scrollPos:f,scrollDirection:h,container:c.container,isDocument:d};return arguments.length?void 0!==t[e]?t[e]:void 0:t},this.loglevel=function(e){return arguments.length?(c.loglevel!=e&&(c.loglevel=e),l):c.loglevel},this.enabled=function(e){return arguments.length?(m!=e&&(m=!!e,l.updateScene(u,!0)),l):m},this.destroy=function(e){t.clearTimeout(i);for(var r=u.length;r--;)u[r].destroy(e);return c.container.off("scroll resize",F),v?TweenLite.ticker.removeEventListener("tick",y):c.container.off("scroll resize",y),null},w(),l},n=function(n){var o,a,l,c,u,g,f,h={onCenter:.5,onEnter:1,onLeave:0},d="ScrollScene",p={duration:0,offset:0,triggerElement:null,triggerHook:"onCenter",reverse:!0,tweenChanges:!1,loglevel:2},v=this,m=e.extend({},p,n),w="BEFORE",E=0,S={start:0,end:0},y=0,F=!0,b={unknownOptionSupplied:function(){e.each(m,function(e){p.hasOwnProperty(e)||delete m[e]})},duration:function(){if(e.isFunction(m.duration)){o=m.duration;try{m.duration=parseFloat(o())}catch(t){o=void 0,m.duration=p.duration}}else m.duration=parseFloat(m.duration),(!e.isNumeric(m.duration)||m.duration<0)&&(m.duration=p.duration)},offset:function(){m.offset=parseFloat(m.offset),e.isNumeric(m.offset)||(m.offset=p.offset)},triggerElement:function(){null!==m.triggerElement&&0===e(m.triggerElement).length&&(m.triggerElement=p.triggerElement)},triggerHook:function(){m.triggerHook in h||(m.triggerHook=e.isNumeric(m.triggerHook)?Math.max(0,Math.min(parseFloat(m.triggerHook),1)):p.triggerHook)},reverse:function(){m.reverse=!!m.reverse},tweenChanges:function(){m.tweenChanges=!!m.tweenChanges}},T=function(){z(),v.on("change.internal",function(e){"loglevel"!==e.what&&"tweenChanges"!==e.what&&("triggerElement"===e.what?I():"reverse"===e.what&&v.update())}).on("shift.internal",function(e){C(),v.update(),("AFTER"===w&&"duration"===e.reason||"DURING"===w&&0===m.duration)&&P()}).on("progress.internal",function(){x(),P()}).on("destroy",function(e){e.preventDefault()})},z=function(t){if(arguments.length)e.isArray(t)||(t=[t]);else{t=[];for(var r in b)t.push(r)}e.each(t,function(e,t){b[t]&&b[t]()})},R=function(e,t){var r=!1,n=m[e];return m[e]!=t&&(m[e]=t,z(e),r=n!=m[e]),r},C=function(){S={start:y+m.offset},a&&m.triggerElement&&(S.start-=a.info("size")*v.triggerHook()),S.end=S.start+m.duration},D=function(e){if(o){var t="duration";R(t,o.call(v))&&!e&&(v.trigger("change",{what:t,newval:m[t]}),v.trigger("shift",{reason:t}))}},I=function(t){var r=0;if(a&&m.triggerElement){for(var n=e(m.triggerElement).first(),o=a.info(),s=i(o.container),l=o.vertical?"top":"left";n.parent().data("ScrollMagicPinSpacer");)n=n.parent();var c=i(n);o.isDocument||(s[l]-=o.scrollPos),r=c[l]-s[l]}var u=r!=y;y=r,u&&!t&&v.trigger("shift",{reason:"triggerElementPosition"})},x=function(e){if(l){var t=e>=0&&1>=e?e:E;if(-1===l.repeat())if("DURING"===w&&l.paused())l.play();else{if("DURING"===w||l.paused())return!1;l.pause()}else{if(t==l.progress())return!1;0===m.duration?"DURING"===w?l.play():l.reverse():m.tweenChanges?l.tweenTo(t*l.duration()):l.progress(t).pause()}return!0}return!1},P=function(e){if(c&&a){var t=a.info();if(e||"DURING"!==w){var r={position:u.inFlow?"relative":"absolute",top:0,left:0},n=c.css("position")!=r.position;u.pushFollowers?m.duration>0&&("AFTER"===w&&0===parseFloat(u.spacer.css("padding-top"))?n=!0:"BEFORE"===w&&0===parseFloat(u.spacer.css("padding-bottom"))&&(n=!0)):r[t.vertical?"top":"left"]=m.duration*E,c.css(r),n&&(c.removeClass(u.pinnedClass),k())}else{"fixed"!=c.css("position")&&(c.css("position","fixed"),k(),c.addClass(u.pinnedClass));var o=i(u.spacer,!0),s=m.reverse||0===m.duration?t.scrollPos-S.start:Math.round(E*m.duration*10)/10;o.top-=parseFloat(u.spacer.css("margin-top")),o[t.vertical?"top":"left"]+=s,c.css({top:o.top,left:o.left})}}},k=function(){if(c&&a&&u.inFlow){var r="AFTER"===w,n="BEFORE"===w,i="DURING"===w,o="fixed"==c.css("position"),l=a.info("vertical"),g=u.spacer.children().first(),f=s(u.spacer.css("display")),h={};f?(h["margin-top"]=n||i&&o?c.css("margin-top"):"auto",h["margin-bottom"]=r||i&&o?c.css("margin-bottom"):"auto"):h["margin-top"]=h["margin-bottom"]="auto",u.relSize.width||u.relSize.autoFullWidth?o?e(t).width()==u.spacer.parent().width()?c.css("width",u.relSize.autoFullWidth?"100%":"inherit"):c.css("width",u.spacer.width()):c.css("width","100%"):(h["min-width"]=g.outerWidth(!g.is(c)),h.width=o?h["min-width"]:"auto"),u.relSize.height?o?e(t).height()==u.spacer.parent().height()?c.css("height","inherit"):c.css("height",u.spacer.height()):c.css("height","100%"):(h["min-height"]=g.outerHeight(!f),h.height=o?h["min-height"]:"auto"),u.pushFollowers&&(h["padding"+(l?"Top":"Left")]=m.duration*E,h["padding"+(l?"Bottom":"Right")]=m.duration*(1-E)),u.spacer.css(h)}},O=function(){a&&c&&"DURING"===w&&!a.info("isDocument")&&P()},N=function(){a&&c&&"DURING"===w&&((u.relSize.width||u.relSize.autoFullWidth)&&e(t).width()!=u.spacer.parent().width()||u.relSize.height&&e(t).height()!=u.spacer.parent().height())&&k()},U=function(e){a&&c&&"DURING"===w&&a.scrollTo(a.info("scrollPos")-(e.originalEvent.wheelDelta/3||30*-e.originalEvent.detail))};return this.parent=function(){return a},this.duration=function(t){var r="duration";return arguments.length?(e.isFunction(t)||(o=void 0),R(r,t)&&(v.trigger("change",{what:r,newval:m[r]}),v.trigger("shift",{reason:r})),v):m[r]},this.offset=function(e){var t="offset";return arguments.length?(R(t,e)&&(v.trigger("change",{what:t,newval:m[t]}),v.trigger("shift",{reason:t})),v):m[t]},this.triggerElement=function(e){var t="triggerElement";return arguments.length?(R(t,e)&&v.trigger("change",{what:t,newval:m[t]}),v):m[t]},this.triggerHook=function(t){var r="triggerHook";return arguments.length?(R(r,t)&&(v.trigger("change",{what:r,newval:m[r]}),v.trigger("shift",{reason:r})),v):e.isNumeric(m[r])?m[r]:h[m[r]]},this.reverse=function(e){var t="reverse";return arguments.length?(R(t,e)&&v.trigger("change",{what:t,newval:m[t]}),v):m[t]},this.tweenChanges=function(e){var t="tweenChanges";return arguments.length?(R(t,e)&&v.trigger("change",{what:t,newval:m[t]}),v):m[t]},this.loglevel=function(e){var t="loglevel";return arguments.length?(R(t,e)&&v.trigger("change",{what:t,newval:m[t]}),v):m[t]},this.state=function(){return w},this.triggerPosition=function(){var e=m.offset;return a&&(e+=m.triggerElement?y:a.info("size")*v.triggerHook()),e},this.triggerOffset=function(){return v.triggerPosition()},this.scrollOffset=function(){return S.start},this.update=function(e){if(a)if(e)if(a.enabled()&&F){var t,r=a.info("scrollPos");t=m.duration>0?(r-S.start)/(S.end-S.start):r>=S.start?1:0,v.trigger("update",{startPos:S.start,endPos:S.end,scrollPos:r}),v.progress(t)}else c&&"DURING"===w&&P(!0);else a.updateScene(v,!1);return v},this.refresh=function(){return D(),I(),v},this.progress=function(e){if(arguments.length){var t=!1,r=w,n=a?a.info("scrollDirection"):"PAUSED",i=m.reverse||e>=E;if(0===m.duration?(t=E!=e,E=1>e&&i?0:1,w=0===E?"BEFORE":"DURING"):0>=e&&"BEFORE"!==w&&i?(E=0,w="BEFORE",t=!0):e>0&&1>e&&i?(E=e,w="DURING",t=!0):e>=1&&"AFTER"!==w?(E=1,w="AFTER",t=!0):"DURING"!==w||i||P(),t){var o={progress:E,state:w,scrollDirection:n},s=w!=r,l=function(e){v.trigger(e,o)};s&&"DURING"!==r&&(l("enter"),l("BEFORE"===r?"start":"end")),l("progress"),s&&"DURING"!==w&&(l("BEFORE"===w?"start":"end"),l("leave"))}return v}return E},this.setTween=function(e){l&&v.removeTween();try{l=new TimelineMax({smoothChildTiming:!0}).add(e).pause()}catch(t){}finally{return e.repeat&&-1===e.repeat()&&(l.repeat(-1),l.yoyo(e.yoyo())),z("checkIfTriggerElementIsTweened"),x(),v}},this.removeTween=function(e){return l&&(e&&x(0),l.kill(),l=void 0),v},this.setPin=function(r,n){var i={pushFollowers:!0,spacerClass:"scrollmagic-pin-spacer",pinnedClass:""};if(n=e.extend({},i,n),r=e(r).first(),0===r.length)return v;if("fixed"==r.css("position"))return v;if(c){if(c===r)return v;v.removePin()}c=r,c.parent().hide();var o="absolute"!=c.css("position"),a=c.css(["display","top","left","bottom","right"]),l=c.css(["width","height"]);c.parent().show(),"0px"===l.width&&o&&s(a.display),!o&&n.pushFollowers&&(n.pushFollowers=!1);var g=e("
").addClass(n.spacerClass).css(a).data("ScrollMagicPinSpacer",!0).css({position:o?"relative":"absolute","margin-left":"auto","margin-right":"auto","box-sizing":"content-box"}),f=c[0].style;return u={spacer:g,relSize:{width:"%"===l.width.slice(-1),height:"%"===l.height.slice(-1),autoFullWidth:"0px"===l.width&&o&&s(a.display)},pushFollowers:n.pushFollowers,inFlow:o,origStyle:{width:f.width||"",position:f.position||"",top:f.top||"",left:f.left||"",bottom:f.bottom||"",right:f.right||"","box-sizing":f["box-sizing"]||"","-moz-box-sizing":f["-moz-box-sizing"]||"","-webkit-box-sizing":f["-webkit-box-sizing"]||""},pinnedClass:n.pinnedClass},u.relSize.width&&g.css("width",l.width),u.relSize.height&&g.css("height",l.height),c.before(g).appendTo(g).css({position:o?"relative":"absolute",top:"auto",left:"auto",bottom:"auto",right:"auto"}),(u.relSize.width||u.relSize.autoFullWidth)&&c.css("box-sizing","border-box"),e(t).on("scroll."+d+"_pin resize."+d+"_pin",O),c.on("mousewheel DOMMouseScroll",U),P(),v},this.removePin=function(r){return c&&(r||!a?(c.insertBefore(u.spacer).css(u.origStyle),u.spacer.remove()):"DURING"===w&&P(!0),e(t).off("scroll."+d+"_pin resize."+d+"_pin"),c.off("mousewheel DOMMouseScroll",U),c=void 0),v},this.setClassToggle=function(t,r){var n=e(t);return 0===n.length||"string"!==e.type(r)?v:(g=r,f=n,v.on("enter.internal_class leave.internal_class",function(e){f.toggleClass(g,"enter"===e.type)}),v)},this.removeClassToggle=function(e){return f&&e&&f.removeClass(g),v.off("start.internal_class end.internal_class"),g=void 0,f=void 0,v},this.addTo=function(e){return e instanceof r&&a!=e&&(a&&a.removeScene(v),a=e,z(),D(!0),I(!0),C(),k(),a.info("container").on("resize."+d,function(){N(),v.triggerHook()>0&&v.trigger("shift",{reason:"containerSize"})}),e.addScene(v),v.update()),v},this.enabled=function(e){return arguments.length?(F!=e&&(F=!!e,v.update(!0)),v):F},this.remove=function(){if(a){a.info("container").off("resize."+d);var e=a;a=void 0,e.removeScene(v)}return v},this.destroy=function(e){return v.removeTween(e),v.removePin(e),v.removeClassToggle(e),v.trigger("destroy",{reset:e}),v.remove(),v.off("start end enter leave progress change update shift destroy shift.internal change.internal progress.internal"),null},this.on=function(t,r){if(e.isFunction(r)){var n=e.trim(t).toLowerCase().replace(/(\w+)\.(\w+)/g,"$1."+d+"_$2").replace(/( |^)(\w+)(?= |$)/g,"$1$2."+d);e(v).on(n,r)}return v},this.off=function(t,r){var n=e.trim(t).toLowerCase().replace(/(\w+)\.(\w+)/g,"$1."+d+"_$2").replace(/( |^)(\w+)(?= |$)/g,"$1$2."+d+"$3");return e(v).off(n,r),v},this.trigger=function(t,r){var n=e.Event(e.trim(t).toLowerCase(),r);return e(v).trigger(n),v},T(),v};r.prototype.version="1.1.0",t.ScrollScene=n,t.ScrollMagic=r;var i=function(t,r){var n={top:0,left:0},i=t[0];if(i)if(i.getBoundingClientRect){var o=i.getBoundingClientRect();n.top=o.top,n.left=o.left,r||(n.top+=e(document).scrollTop(),n.left+=e(document).scrollLeft())}else n=t.offset()||n,r&&(n.top-=e(document).scrollTop(),n.left-=e(document).scrollLeft());return n},o=function(e){return"object"==typeof HTMLElement?e instanceof HTMLElement:e&&"object"==typeof e&&null!==e&&1===e.nodeType&&"string"==typeof e.nodeName},s=function(e){return["block","flex","list-item","table","-webkit-box"].indexOf(e)>-1}}(jQuery,window);