artemsemkin

Rhye HTML5 Templatee: fix for non-disappearing curtains

Mar 9th, 2021 (edited)
416
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* ======================================================================== */
  2. /* 12. PJAX Finish Loading */
  3. /* ======================================================================== */
  4. function PJAXFinishLoading(data) {
  5.   return new Promise((resolve) => {
  6.  
  7.     const $transitionCurtains = $('#js-page-transition-curtain, #js-header-curtain-transition');
  8.  
  9.     // Clear transition curtains
  10.     gsap.effects.setCurtain($transitionCurtains, {
  11.       display: 'none',
  12.     });
  13.  
  14.     // Transition ended event
  15.     window.dispatchEvent(new CustomEvent('arts/barba/transition/end'));
  16.  
  17.     // Hide spinner
  18.     if (typeof window.$spinner !== 'undefined' && window.$spinner.length) {
  19.       gsap.to(window.$spinner, 0.6, {
  20.         autoAlpha: 0
  21.       });
  22.     }
  23.  
  24.     // audio backgrounds
  25.     if (typeof window.AudioBackground !== 'undefined') {
  26.  
  27.       if (window.AudioBackground.isAudioSrc()) {
  28.         window.AudioBackground.controller.reveal(true);
  29.       } else {
  30.         window.AudioBackground.controller.reveal(false);
  31.       }
  32.     }
  33.  
  34.     // Re-init page header
  35.     if (typeof window.theme.header !== 'undefined') {
  36.       window.theme.header.run();
  37.     }
  38.  
  39.     // re-enable ScrollMagic scenes
  40.     window.SMController.enabled(true);
  41.     window.SMController.update(true);
  42.  
  43.     setTimeout(() => {
  44.  
  45.       // remove cloned image if it exists
  46.       $('.clone').remove();
  47.  
  48.       // unlock scroll
  49.       Scroll.lock(false);
  50.  
  51.       window.$barbaWrapper.removeClass('cursor-progress');
  52.       $('.menu').removeClass('menu_disabled');
  53.  
  54.     }, 100);
  55.  
  56.     // scroll to anchor from URL hash
  57.     Scroll.scrollToAnchorFromHash(600);
  58.  
  59.     resolve(true);
  60.  
  61.   });
  62.  
  63. }
RAW Paste Data