Created
          April 27, 2022 07:42 
        
      - 
      
- 
        Save deepakgudi-pixel/8d1e2be668eac26880e1cc29dcbe5d8c to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | mport "../libs/gsap/gsap.min"; | |
| import ScrollMagic from "../libs/smooth/ScrollMagic"; | |
| import Scrollbar from "../libs/smooth/smooth-scrollbar"; | |
| export default class SmoothScroll { | |
| constructor() { | |
| this.init(); | |
| } | |
| init() { | |
| let isChrome = | |
| /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor); | |
| console.log("is Chrome ? ", isChrome); | |
| let scenes = []; | |
| let y = 0; | |
| // initial smooth-scrollbar | |
| let scroll = Scrollbar.init(document.querySelector("#container-scroll")); | |
| // initiate ScrollMagic Controller | |
| let controller = new ScrollMagic.Controller({ | |
| refreshInterval: 0 | |
| }); | |
| // update scrollY controller | |
| if (isChrome) { | |
| controller.scrollPos(function() { | |
| return y; | |
| }); | |
| } | |
| // listener smooth-scrollbar, update controller | |
| scroll.addListener(function(status) { | |
| y = status.offset.y; | |
| if (isChrome) { | |
| controller.update(); | |
| } else { | |
| scenes.forEach(function(scene) { | |
| scene.refresh(); | |
| }); | |
| } | |
| }); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment