1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
function initializeScrollRevealTriggers(){function e(e){const a=e.hasClass("awb-title__scroll-reveal--color_change")?.9:.5,t=void 0!==e.data("scroll-reveal-behavior")?e.data("scroll-reveal-behavior"):"always";let i={trigger:e,start:"top 80%",end:"clamp(top 20%)",scrub:a};return"play"===t&&(i.onLeave=e=>e.getTween().eventCallback("onComplete",()=>e.kill(!1))),i}function a(a,t){triggerOptions=e(a),triggerOptions.scrub=!1,triggerOptions.onLeave=()=>{t.scrollTrigger.disable(!1),t.play()},triggerOptions.onLeaveBack=()=>{t.pause(),t.progress(0),t.scrollTrigger.enable(!0)},ScrollTrigger.create(triggerOptions)}jQuery(window).on("fusion-element-render-fusion_title",(function(e,a){const t=jQuery('div[data-cid="'+a+'"]').find('[class*="awb-title__scroll-reveal"]');t.length&&t.reinitScrollReveal()})),jQuery(window).on("fusion-resize-horizontal",(function(){jQuery('.fusion-title[class*="awb-title__scroll-reveal"]').each((function(){jQuery(this).reinitScrollReveal()}))})),jQuery.fn.reinitScrollReveal=function(){const e=jQuery(this),a=gsap.getById(e.data("scroll-reveal-counter"));a&&(a.progress(0).kill(),SplitType.revert(e.find(".fusion-title-heading"))),""!==jQuery.trim(e.find(".fusion-title-heading").text())&&setTimeout((function(){switch(e.data("scroll-reveal-effect")){case"color_change":e.awbTitleScrollRevealColorChange();break;case"unblur":e.awbTitleScrollRevealUnblur();break;case"random_assemble":e.awbTitleScrollRevealRandomAssemble();break;case"slide_up":case"slide_down":e.awbTitleScrollRevealSlide();break;case"turn":e.awbTitleScrollRevealTurn();break;case"rotate":e.awbTitleScrollRevealRotate();break;case"scale_up":e.awbTitleScrollRevealScaleUp();break;default:e.awbTitleScrollRevealColorChange()}ScrollTrigger.refresh()}),200)},jQuery.fn.shouldAnimate=function(){return 1===parseInt(jQuery(this).data("scroll-reveal-above-fold"))||0<jQuery(window).scrollTop()&&!jQuery(this).parent().hasClass("fusion-builder-element-content")||jQuery(this).offset().top>.8*jQuery(window).height()},jQuery.fn.awbTitleScrollRevealColorChange=function(){jQuery(this).each((function(){if(!jQuery(this).shouldAnimate())return;const t=jQuery(this),i=t.data("scroll-reveal-counter"),l=t.data("scroll-reveal-basis");if("chars"===l){new SplitType(t.find(".fusion-title-heading"),{tagName:"span",type:"chars, words, lines"})}else{new SplitType(t.find(".fusion-title-heading"),{tagName:"span",types:l})}const r=t.find("."+l.replace("s",""));let o=gsap.timeline({id:i,scrollTrigger:e(t)});o.to(r,{ease:"power1","background-position-x":"0",stagger:t.data("scroll-reveal-stagger"),duration:t.data("scroll-reveal-duration"),delay:t.data("scroll-reveal-delay")}),void 0!==t.data("scroll-reveal-behavior")&&"replay"===t.data("scroll-reveal-behavior")&&a(t,o)}))},jQuery(".awb-title__scroll-reveal--color_change").awbTitleScrollRevealColorChange(),jQuery.fn.awbTitleScrollRevealUnblur=function(){jQuery(this).each((function(){if(!jQuery(this).shouldAnimate())return;const t=jQuery(this),i=t.data("scroll-reveal-counter"),l=t.data("scroll-reveal-basis");if("chars"===l){new SplitType(t.find(".fusion-title-heading"),{tagName:"span",types:"chars, words, lines"})}else{new SplitType(t.find(".fusion-title-heading"),{tagName:"span",types:l})}const r=t.find("."+l.replace("s",""));let o=gsap.timeline({id:i,scrollTrigger:e(t)});o.fromTo(r,{opacity:0,skewX:-20,filter:"blur(8px)"},{ease:"sine",opacity:1,skewX:0,filter:"blur(0px)",stagger:t.data("scroll-reveal-stagger"),duration:t.data("scroll-reveal-duration"),delay:t.data("scroll-reveal-delay")}),void 0!==t.data("scroll-reveal-behavior")&&"replay"===t.data("scroll-reveal-behavior")&&a(t,o)}))},jQuery(".awb-title__scroll-reveal--unblur").awbTitleScrollRevealUnblur(),jQuery.fn.awbTitleScrollRevealRandomAssemble=function(){jQuery(this).each((function(){if(!jQuery(this).shouldAnimate())return;const t=jQuery(this),i=t.data("scroll-reveal-counter"),l=(new SplitType(t.find(".fusion-title-heading"),{tagName:"span",types:"words"}),t.find(".word"));let r=gsap.timeline({id:i,scrollTrigger:e(t)});r.fromTo(l,{opacity:0,z:()=>gsap.utils.random(200,950),xPercent:e=>gsap.utils.random(-150,150),yPercent:e=>gsap.utils.random(-20,20),rotationX:()=>gsap.utils.random(-90,90),zoom:()=>gsap.utils.random(80,120)+"%"},{ease:"power1.inOut",opacity:1,rotationX:0,rotationY:0,xPercent:0,yPercent:0,z:0,zoom:"100%",stagger:{each:t.data("scroll-reveal-stagger"),from:"random"},duration:t.data("scroll-reveal-duration"),delay:t.data("scroll-reveal-delay")}),void 0!==t.data("scroll-reveal-behavior")&&"replay"===t.data("scroll-reveal-behavior")&&a(t,r)}))},jQuery(".awb-title__scroll-reveal--random_assemble").awbTitleScrollRevealRandomAssemble(),jQuery.fn.awbTitleScrollRevealSlide=function(){jQuery(this).each((function(){if(!jQuery(this).shouldAnimate())return;const t=jQuery(this),i=t.data("scroll-reveal-counter"),l=t.data("scroll-reveal-basis"),r=t.hasClass("awb-title__scroll-reveal--slide_up")?"":"-",o={lines:{y:r+"150%"},words:{y:r+"80%"},chars:{y:r+"60%"}};if("chars"===l){new SplitType(t.find(".fusion-title-heading"),{tagName:"span",types:"chars, words, lines"})}else{new SplitType(t.find(".fusion-title-heading"),{tagName:"span",types:l})}const n=t.find("."+l.replace("s",""));let s=gsap.timeline({id:i,scrollTrigger:e(t)});s.from(n,{y:o[l].y,rotationX:-90,opacity:0,ease:"power1.inOut",stagger:t.data("scroll-reveal-stagger"),duration:t.data("scroll-reveal-duration"),delay:t.data("scroll-reveal-delay")}),void 0!==t.data("scroll-reveal-behavior")&&"replay"===t.data("scroll-reveal-behavior")&&a(t,s)}))},jQuery(".awb-title__scroll-reveal--slide_up, .awb-title__scroll-reveal--slide_down").awbTitleScrollRevealSlide(),jQuery.fn.awbTitleScrollRevealTurn=function(){jQuery(this).each((function(){if(!jQuery(this).shouldAnimate())return;const t=jQuery(this),i=t.data("scroll-reveal-counter"),l=t.data("scroll-reveal-basis"),r={lines:{basis:"lines",perspective:"1000px"},words:{basis:"words, lines",perspective:"500px"},chars:{basis:"chars, words, lines",perspective:"200px"}};new SplitType(t.find(".fusion-title-heading"),{tagName:"span",types:r[l].basis});targetElement=t.find("."+l.replace("s","")),targetElement.parent().css("perspective",r[l].perspective);let o=gsap.timeline({id:i,scrollTrigger:e(t)});o.fromTo(targetElement,{rotationY:90,opacity:0,scale:1,transformOrigin:"center center"},{ease:"none",rotationY:0,opacity:1,scale:1,duration:t.data("scroll-reveal-duration"),stagger:t.data("scroll-reveal-stagger"),delay:t.data("scroll-reveal-delay")}),void 0!==t.data("scroll-reveal-behavior")&&"replay"===t.data("scroll-reveal-behavior")&&a(t,o)}))},jQuery(".awb-title__scroll-reveal--turn").awbTitleScrollRevealTurn(),jQuery.fn.awbTitleScrollRevealRotate=function(){jQuery(this).each((function(){if(!jQuery(this).shouldAnimate())return;const t=jQuery(this),i=t.data("scroll-reveal-counter");new SplitType(t.find(".fusion-title-heading"),{tagName:"span",types:"chars, words"});t.find(".word").each((function(){let l=jQuery(this),r=l.find(".char"),o=r.length;l.data("scroll-reveal-behavior",t.data("scroll-reveal-behavior")),r.css("perspective","1000px");let n=gsap.timeline({id:i,scrollTrigger:e(l)});n.fromTo(r,{x:e=>{const a=e<Math.ceil(o/2)?e:Math.ceil(o/2)-Math.abs(Math.floor(o/2)-e)-1;return 200*(o%2?Math.abs(Math.ceil(o/2)-1-a):Math.abs(Math.ceil(o/2)-a))*(e<o/2?-1:1)},y:e=>60*(e<Math.ceil(o/2)?e:Math.ceil(o/2)-Math.abs(Math.floor(o/2)-e)-1),rotationY:-270,rotationZ:e=>{const a=e<Math.ceil(o/2)?e:Math.ceil(o/2)-Math.abs(Math.floor(o/2)-e)-1;return e<o/2?8*Math.abs(a-o/2):-1*Math.abs(a-o/2)*8}},{ease:"power2.inOut",x:0,y:0,rotationZ:0,rotationY:0,scale:1,duration:t.data("scroll-reveal-duration"),delay:t.data("scroll-reveal-delay")}),void 0!==l.data("scroll-reveal-behavior")&&"replay"===l.data("scroll-reveal-behavior")&&a(l,n)}))}))},jQuery(".awb-title__scroll-reveal--rotate").awbTitleScrollRevealRotate(),jQuery.fn.awbTitleScrollRevealScaleUp=function(){jQuery(this).each((function(){if(!jQuery(this).shouldAnimate())return;const t=jQuery(this),i=t.data("scroll-reveal-counter");new SplitType(t.find(".fusion-title-heading"),{tagName:"span",types:"chars, words, lines"});t.find(".line").each((function(){let l=jQuery(this).find(".word"),r=l.find(".char");l.css("perspective","1000px");let o=gsap.timeline({id:i,scrollTrigger:e(l)});o.fromTo(r,{opacity:.15,x:-20,z:-1e3},{ease:"back.out(1.2)",opacity:1,x:0,z:0,duration:t.data("scroll-reveal-duration"),stagger:t.data("scroll-reveal-stagger"),delay:t.data("scroll-reveal-delay")}),void 0!==l.data("scroll-reveal-behavior")&&"replay"===l.data("scroll-reveal-behavior")&&a(l,o)}))}))},jQuery(".awb-title__scroll-reveal--scale_up").awbTitleScrollRevealScaleUp()}!function(e){"use strict";e.fn.awbAnimateTitleHighlightsAndRotations=function(){"IntersectionObserver"in window?e.each(fusion.getObserverSegmentation(e(this)),(function(a){var t=fusion.getAnimationIntersectionData(a),i=new IntersectionObserver((function(a,t){e.each(a,(function(a,l){var r=e(l.target);fusion.shouldObserverEntryAnimate(l,t)&&(e(r).hasClass("fusion-title-rotating")&&e(r).animateTitleRotations(),e(r).hasClass("fusion-title-highlight")&&e(r).animateTitleHighlights(),i.unobserve(l.target))}))}),t);e(this).each((function(){i.observe(this)}))})):e(this).each((function(){var a=e(this);e(a).hasClass("fusion-title-rotating")&&e(a).animateTitleRotations(),e(a).hasClass("fusion-title-highlight")&&e(a).animateTitleHighlights()}))},e.fn.animateTitleRotations=function(){var a=e(this),t=a.find(".fusion-animated-texts-wrapper"),i=a.hasClass("fusion-animate-loop"),l=e(a).closest("[data-animationduration]").data("animationduration"),r=void 0!==l?200*parseFloat(l):0;t.removeData("textillate"),e(a).find(".fusion-textillate").remove(),e(a).is(".fusion-title-typeIn,.fusion-title-clipIn")||t.awbAnimatedTitleRotationWidth(),t.textillate({selector:".fusion-animated-texts",type:t.attr("data-length"),minDisplayTime:t.attr("data-minDisplayTime"),loop:i,initialDelay:r})},e.fn.animateTitleHighlights=function(){e(this).hasClass("fusion-highlight-marker")?e(this).find(".fusion-highlighted-text").addClass("awb-animate"):e(this).find(".fusion-highlighted-text-wrapper svg").addClass("awb-animate")},e.fn.awbAnimatedTitleRotationWidth=function(){var a=e(this),t=a.find(".fusion-animated-texts"),i=0,l=0,r=!1;i=parseInt(a.find(".fusion-animated-text").css("font-size")),i*=.6,t.is(":visible")||(r=!0,t.show()),e(a).find(".fusion-animated-text").each((function(){var a=e(this).width();a>l&&(l=a)})),r&&t.hide(),a.css("width",l+i)},e.fn.awbAnimatedTitleRotationWidthRecalc=function(){e(this).each((function(){e(this).is(".fusion-title-typeIn,.fusion-title-clipIn")||e(this).find(".fusion-animated-texts-wrapper").awbAnimatedTitleRotationWidth()}))}}(jQuery),jQuery(window).on("load",(function(){setTimeout((function(){jQuery(".fusion-title-rotating, .fusion-title-highlight").awbAnimateTitleHighlightsAndRotations()}),400),jQuery(window).on("fusion-resize-horizontal",(function(){jQuery(".fusion-title-rotating").awbAnimatedTitleRotationWidthRecalc()}))})),jQuery(window).on("fusion-column-resized fusion-element-render-fusion_title",(function(e,a){var t=jQuery('div[data-cid="'+a+'"]').find(".fusion-title-rotating, .fusion-title-highlight");t.length&&(t.awbAnimateTitleHighlightsAndRotations(),t.awbAnimatedTitleRotationWidthRecalc())})),gsap.registerPlugin(ScrollTrigger),jQuery(window).on("load",(function(){initializeScrollRevealTriggers(),setTimeout((function(){ScrollTrigger.refresh()}),400)})); |