Commit 7480ad61 authored by Michael Iseard's avatar Michael Iseard
Browse files

test build (1.0.1)

parent ff8e5c85
This diff is collapsed.
"use strict";function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var citrus=function(){var t=[],e=function t(e){_classCallCheck(this,t),this.sliderContainer=e,this.slideText=function(t){for(var e={},i=0;i<t.length;i++)e[i]=t[i];return e}(e.children),this.num=e.children.length,this.imgUrls=function(t){var e=Array.from(t.children).map(function(t){return t.getElementsByTagName("img")[0].src}),i=t.getElementsByTagName("img");for(;i[0];)i[0].remove();return e}(e),this.settings={animateText:!0,animationDuration:.8,autoHeight:!1,autoPause:!0,effect:!1,height:"100%",paused:!1,showArrows:!0,showIndicators:!0,slideDuration:5e3,slideIndex:0,slideTransition:"pan",width:"100%"}};e.prototype.goToSlide=function(t){this.settings.slideIndex=t,n(this)},e.prototype.stop=function(){this.settings.paused=!0,clearTimeout(this.intervalSlideChange)},e.prototype.play=function(){this.settings.paused=!1,r(this)},e.prototype.prevSlide=function(){this.settings.slideIndex--,n(this)},e.prototype.nextSlide=function(){this.settings.slideIndex++,n(this)},e.prototype.reset=function(){window.removeEventListener("scroll",a),clearTimeout(this.intervalSlideChange),s(this),r(this)};var i=Array.from(document.getElementsByClassName("citrus-slider"));function s(t){var e=t.settings.height;!0===t.settings.autoHeight&&(e=function(t){for(var e=0,i=0;i<t.num;i++){var s=t.slideText[i].offsetHeight;e<s&&(e=s)}return(e+=250)+"px"}(t)),t.sliderContainer.setAttribute("style","width:"+t.settings.width+"; height:"+e),t.sliderHeight=t.sliderContainer.offsetHeight,t.sliderContainer.setAttribute("class","citrus-slider"),t.sliderContainer.classList.add("transition-"+t.settings.slideTransition),t.settings.effect&&t.sliderContainer.classList.add("effect-"+t.settings.effect),t.settings.animateText&&t.sliderContainer.classList.add("animate-text"),function(t){var e=document.createDocumentFragment(),i=document.createElement("DIV");0==t.settings.showArrows?i.setAttribute("class","citrus-arrows hidden"):i.setAttribute("class","citrus-arrows");var s=document.createElement("DIV");s.setAttribute("class","slide-arrow left-arrow");var r=document.createElement("DIV");r.setAttribute("class","slide-arrow right-arrow"),i.appendChild(s),i.appendChild(r),e.appendChild(i),t.arrows=[s,r];var d=document.createElement("DIV");t.slides=d,d.setAttribute("class","citrus-slides"),d.setAttribute("style","animation-duration:"+t.settings.animationDuration+"s;transition-duration:"+t.settings.animationDuration+"s;"),"pan"===t.settings.slideTransition&&(d.style.width=t.num+"00%");"pan"===t.settings.slideTransition&&(d.style.width=t.num+"00%",d.style.transform="translateX(-"+t.settings.slideIndex/t.num*100+"%)");for(var l=0;l<t.num;l++){var o=document.createElement("DIV");l===t.settings.slideIndex?o.setAttribute("class","slide-wrap current-slide"):o.setAttribute("class","slide-wrap");var c=document.createElement("DIV");c.setAttribute("class","slide");var u=t.slideText[l];u.setAttribute("class","slide-text"),c.style.backgroundImage="url("+t.imgUrls[l]+")",o.appendChild(c),o.appendChild(u),d.appendChild(o)}e.appendChild(d),t.indicators=[];var g=document.createElement("DIV");0==t.settings.showIndicators?g.setAttribute("class","citrus-indicators hidden"):g.setAttribute("class","citrus-indicators");for(var m=0;m<t.num;m++){var h=document.createElement("SPAN");m===t.settings.slideIndex?h.setAttribute("class","slide-indicator current-indicator"):h.setAttribute("class","slide-indicator"),h.setAttribute("data-slide",m),g.appendChild(h),e.appendChild(g),t.indicators[m]=h}t.sliderContainer.innerHTML="",t.sliderContainer.appendChild(e),"parallax"===t.settings.effect&&function(t){a(t),window.addEventListener("scroll",function(){"parallax"===t.settings.effect&&a(t)})}(t);!function(t){var e=!0,i=!1,s=void 0;try{for(var r,a=t.arrows[Symbol.iterator]();!(e=(r=a.next()).done);e=!0){var d=r.value;d.addEventListener("click",function(e){t.settings.autoPause&&(t.settings.paused=!0),t.sliderContainer.classList.contains("animating")||(t.settings.prevIndex=t.settings.slideIndex,e.target.classList.contains("left-arrow")?t.settings.slideIndex--:e.target.classList.contains("right-arrow")&&t.settings.slideIndex++,n(t))})}}catch(t){i=!0,s=t}finally{try{!e&&a.return&&a.return()}finally{if(i)throw s}}var l=!0,o=!1,c=void 0;try{for(var u,g=t.indicators[Symbol.iterator]();!(l=(u=g.next()).done);l=!0){var m=u.value;m.addEventListener("click",function(e){t.settings.autoPause&&(t.settings.paused=!0),t.sliderContainer.classList.contains("animating")||!1===e.target.classList.contains("current-indicator")&&(t.settings.prevIndex=t.settings.slideIndex,t.settings.slideIndex=Number(e.target.dataset.slide),n(t))})}}catch(t){o=!0,c=t}finally{try{!l&&g.return&&g.return()}finally{if(o)throw c}}}(t)}(t)}function n(t){if(clearTimeout(t.intervalSlideChange),t.prev=t.sliderContainer.getElementsByClassName("current-slide")[0],t.settings.slideIndex<0?(t.settings.slideIndex=t.num-1,t.num&&(t.indicators[0].parentElement.classList.add("transition-last"),setTimeout(function(){t.indicators[0].parentElement.classList.remove("transition-last")},1e3))):t.settings.slideIndex>t.num-1&&(t.settings.slideIndex=0,t.num&&(t.indicators[0].parentElement.classList.add("transition-first"),setTimeout(function(){t.indicators[0].parentElement.classList.remove("transition-first")},1e3))),t.num>1){t.sliderContainer.classList.remove("forwards","backwards");for(var e=0;e<t.num;e++)t.slides.children[e].classList.remove("current-slide","prev-slide","next-slide"),t.num&&t.indicators[e].classList.remove("current-indicator");t.settings.prevIndex<t.settings.slideIndex?t.sliderContainer.classList.add("forwards"):t.sliderContainer.classList.add("backwards"),t.prev.classList.add("prev-slide"),t.settings.slideIndex===t.num-1?t.slides.children[0].classList.add("next-slide"):t.slides.children[t.settings.slideIndex+1]&&t.slides.children[t.settings.slideIndex+1].classList.add("next-slide"),t.slides.children[t.settings.slideIndex].classList.add("current-slide"),t.num&&t.indicators[t.settings.slideIndex].classList.add("current-indicator"),"pan"===t.settings.slideTransition&&(t.sliderContainer.children[1].style.transform="translateX(-"+t.settings.slideIndex/t.num*100+"%)"),t.sliderContainer.classList.add("animating"),t.intervalPrevAnim=setTimeout(function(){t.sliderContainer.classList.remove("animating")},1e3*t.settings.animationDuration),r(t)}}function r(t){!1===t.settings.paused&&(t.intervalSlideChange=setTimeout(function(){t.settings.prevIndex=t.settings.slideIndex,t.settings.slideIndex++,n(t)},t.settings.slideDuration))}function a(t){var e=window.innerHeight;if(function(t,e,i){var s,n=t.getBoundingClientRect().top+i,r=t.getBoundingClientRect().bottom-i;s=!0===e?n<window.innerHeight&&r>=0:n>=0&&r<=window.innerHeight;return s}(t.sliderContainer,!0,0))for(var i=t.sliderContainer.getBoundingClientRect().top/e*(.3*t.sliderHeight),s=0;s<t.num;s++)t.slides.children[s].children[0].style.backgroundPosition="center calc(50% - "+i+"px)"}return i.forEach(function(n,a){t[a]=new e(i[a]);var d=t[a];!function(t,e){if(t.sliderContainer.hasAttribute("data-citrus")){var i=JSON.parse(t.sliderContainer.dataset.citrus),s=!0,n=!1,r=void 0;try{for(var a,d=Object.keys(i)[Symbol.iterator]();!(s=(a=d.next()).done);s=!0){var l=a.value;t.settings[l]=i[l]}}catch(t){n=!0,r=t}finally{try{!s&&d.return&&d.return()}finally{if(n)throw r}}t.sliderContainer.removeAttribute("data-citrus"),t.settings.slideIndex>t.num||t.settings.slideIndex<=0?t.settings.slideIndex=0:t.settings.slideIndex--}"function"==typeof e&&e(t)}(d,s),r(d)}),t}();
\ No newline at end of file
"use strict";function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var citrus=function(){var t=[],e=function t(e){_classCallCheck(this,t),this.sliderContainer=e,this.slideText=function(t){for(var e={},i=0;i<t.length;i++)e[i]=t[i];return e}(e.children),this.num=e.children.length,this.imgUrls=function(t){var e=Array.from(t.children).map(function(t){return t.getElementsByTagName("img")[0].src}),i=t.getElementsByTagName("img");for(;i[0];)i[0].remove();return e}(e),this.settings={animateText:!0,animationDuration:.8,autoHeight:!1,autoPause:!0,effect:!1,height:"100%",paused:!1,showArrows:!0,showIndicators:!0,slideDuration:5e3,slideIndex:0,slideTransition:"pan",width:"100%"}};e.prototype.goToSlide=function(t){this.settings.slideIndex=t,n(this)},e.prototype.stop=function(){this.settings.paused=!0,clearTimeout(this.intervalSlideChange)},e.prototype.play=function(){this.settings.paused=!1,r(this)},e.prototype.prevSlide=function(){this.settings.slideIndex--,n(this)},e.prototype.nextSlide=function(){this.settings.slideIndex++,n(this)},e.prototype.reset=function(){window.removeEventListener("scroll",a),clearTimeout(this.intervalSlideChange),s(this),r(this)};var i=Array.from(document.getElementsByClassName("citrus-slider"));function s(t){var e=t.settings.height;!0===t.settings.autoHeight&&(e=function(t){for(var e=0,i=0;i<t.num;i++){var s=t.slideText[i].offsetHeight;e<s&&(e=s)}return(e+=250)+"px"}(t)),t.sliderContainer.setAttribute("style","width:"+t.settings.width+"; height:"+e),t.sliderHeight=t.sliderContainer.offsetHeight,t.sliderContainer.setAttribute("class","citrus-slider"),t.sliderContainer.classList.add("transition-"+t.settings.slideTransition),t.settings.effect&&t.sliderContainer.classList.add("effect-"+t.settings.effect),t.settings.animateText&&t.sliderContainer.classList.add("animate-text"),function(t){var e=document.createDocumentFragment(),i=document.createElement("DIV");0==t.settings.showArrows?i.setAttribute("class","citrus-arrows hidden"):i.setAttribute("class","citrus-arrows");var s=document.createElement("DIV");s.setAttribute("class","slide-arrow left-arrow");var r=document.createElement("DIV");r.setAttribute("class","slide-arrow right-arrow"),i.appendChild(s),i.appendChild(r),e.appendChild(i),t.arrows=[s,r];var d=document.createElement("DIV");t.slides=d,d.setAttribute("class","citrus-slides"),d.setAttribute("style","animation-duration:"+t.settings.animationDuration+"s;transition-duration:"+t.settings.animationDuration+"s;"),"pan"===t.settings.slideTransition&&(d.style.width=t.num+"00%");"pan"===t.settings.slideTransition&&(d.style.width=t.num+"00%",d.style.transform="translateZ(0) translateX(-"+t.settings.slideIndex/t.num*100+"%)");for(var l=0;l<t.num;l++){var o=document.createElement("DIV");l===t.settings.slideIndex?o.setAttribute("class","slide-wrap current-slide"):o.setAttribute("class","slide-wrap");var c=document.createElement("DIV");c.setAttribute("class","slide");var u=t.slideText[l];u.setAttribute("class","slide-text"),c.style.backgroundImage="url("+t.imgUrls[l]+")",o.appendChild(c),o.appendChild(u),d.appendChild(o)}e.appendChild(d),t.indicators=[];var g=document.createElement("DIV");0==t.settings.showIndicators?g.setAttribute("class","citrus-indicators hidden"):g.setAttribute("class","citrus-indicators");for(var m=0;m<t.num;m++){var f=document.createElement("SPAN");m===t.settings.slideIndex?f.setAttribute("class","slide-indicator current-indicator"):f.setAttribute("class","slide-indicator"),f.setAttribute("data-slide",m),g.appendChild(f),e.appendChild(g),t.indicators[m]=f}t.sliderContainer.innerHTML="",t.sliderContainer.appendChild(e),"parallax"===t.settings.effect&&function(t){a(t),window.addEventListener("scroll",function(){"parallax"===t.settings.effect&&a(t)})}(t);!function(t){var e=!0,i=!1,s=void 0;try{for(var r,a=t.arrows[Symbol.iterator]();!(e=(r=a.next()).done);e=!0){var d=r.value;d.addEventListener("click",function(e){t.settings.autoPause&&(t.settings.paused=!0),t.sliderContainer.classList.contains("animating")||(t.settings.prevIndex=t.settings.slideIndex,e.target.classList.contains("left-arrow")?t.settings.slideIndex--:e.target.classList.contains("right-arrow")&&t.settings.slideIndex++,n(t))})}}catch(t){i=!0,s=t}finally{try{!e&&a.return&&a.return()}finally{if(i)throw s}}var l=!0,o=!1,c=void 0;try{for(var u,g=t.indicators[Symbol.iterator]();!(l=(u=g.next()).done);l=!0){var m=u.value;m.addEventListener("click",function(e){t.settings.autoPause&&(t.settings.paused=!0),t.sliderContainer.classList.contains("animating")||!1===e.target.classList.contains("current-indicator")&&(t.settings.prevIndex=t.settings.slideIndex,t.settings.slideIndex=Number(e.target.dataset.slide),n(t))})}}catch(t){o=!0,c=t}finally{try{!l&&g.return&&g.return()}finally{if(o)throw c}}}(t)}(t)}function n(t){if(clearTimeout(t.intervalSlideChange),t.prev=t.sliderContainer.getElementsByClassName("current-slide")[0],t.settings.slideIndex<0?(t.settings.slideIndex=t.num-1,t.num&&(t.indicators[0].parentElement.classList.add("transition-last"),setTimeout(function(){t.indicators[0].parentElement.classList.remove("transition-last")},1e3))):t.settings.slideIndex>t.num-1&&(t.settings.slideIndex=0,t.num&&(t.indicators[0].parentElement.classList.add("transition-first"),setTimeout(function(){t.indicators[0].parentElement.classList.remove("transition-first")},1e3))),t.num>1){t.sliderContainer.classList.remove("forwards","backwards");for(var e=0;e<t.num;e++)t.slides.children[e].classList.remove("current-slide","prev-slide","next-slide"),t.num&&t.indicators[e].classList.remove("current-indicator");t.settings.prevIndex<t.settings.slideIndex?t.sliderContainer.classList.add("forwards"):t.sliderContainer.classList.add("backwards"),t.prev.classList.add("prev-slide"),t.settings.slideIndex===t.num-1?t.slides.children[0].classList.add("next-slide"):t.slides.children[t.settings.slideIndex+1]&&t.slides.children[t.settings.slideIndex+1].classList.add("next-slide"),t.slides.children[t.settings.slideIndex].classList.add("current-slide"),t.num&&t.indicators[t.settings.slideIndex].classList.add("current-indicator"),"pan"===t.settings.slideTransition&&(t.sliderContainer.children[1].style.transform="translateX(-"+t.settings.slideIndex/t.num*100+"%)"),t.sliderContainer.classList.add("animating"),t.intervalPrevAnim=setTimeout(function(){t.sliderContainer.classList.remove("animating")},1e3*t.settings.animationDuration),r(t)}}function r(t){!1===t.settings.paused&&(t.intervalSlideChange=setTimeout(function(){t.settings.prevIndex=t.settings.slideIndex,t.settings.slideIndex++,n(t)},t.settings.slideDuration))}function a(t){var e=window.innerHeight;if(function(t,e,i){var s,n=t.getBoundingClientRect().top+i,r=t.getBoundingClientRect().bottom-i;s=!0===e?n<window.innerHeight&&r>=0:n>=0&&r<=window.innerHeight;return s}(t.sliderContainer,!0,0))for(var i=t.sliderContainer.getBoundingClientRect().top/e*(.3*t.sliderHeight),s=0;s<t.num;s++)t.slides.children[s].children[0].style.transform="translate3d(0px, 0px, 0px) scale(1.3) translateY( "+-i+"px )"}return i.forEach(function(n,a){t[a]=new e(i[a]);var d=t[a];!function(t,e){if(t.sliderContainer.hasAttribute("data-citrus")){var i=JSON.parse(t.sliderContainer.dataset.citrus),s=!0,n=!1,r=void 0;try{for(var a,d=Object.keys(i)[Symbol.iterator]();!(s=(a=d.next()).done);s=!0){var l=a.value;t.settings[l]=i[l]}}catch(t){n=!0,r=t}finally{try{!s&&d.return&&d.return()}finally{if(n)throw r}}t.sliderContainer.removeAttribute("data-citrus"),t.settings.slideIndex>t.num||t.settings.slideIndex<=0?t.settings.slideIndex=0:t.settings.slideIndex--}"function"==typeof e&&e(t)}(d,s),r(d)}),t}();
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment