Jump to content
Search Community

SagarSurendhrababu

Members
  • Posts

    6
  • Joined

  • Last visited

Posts posted by SagarSurendhrababu

  1. I am sorry , i forgot to copy code for you

     

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Scrolling</title>
        <style>
    .box.active {
      background-colorblue;
    }




     
    body {
      background-color#111;
      background-image:
        linear-gradient(rgba(255,255,255,.072pxtransparent 2px),
        linear-gradient(90degrgba(255,255,255,.072pxtransparent 2px),
        linear-gradient(rgba(255,255,255,.061pxtransparent 1px),
        linear-gradient(90degrgba(255,255,255,.061pxtransparent 1px);
      background-size100px 100px100px 100px20px 20px20px 20px;
      background-position-2px -2px-2px -2px-1px -1px-1px -1px;
    }
     
    .box {
      width100px;
      height100px;
      background-color#28a92b;
      positionabsolute;
      left100px;
      z-index100;
      line-height100px;
      font-size50px;
      text-aligncenter;
    }
     
    .a {
      top200px;
      background-color#8d3dae;
    }
     
    .b {
      top600px;
    }
     
    .c {
      top1000px;
      background-color#e26c16;
    }
     
    .ghost {
      top1000px;
      background-color#444;
    }
     
    .line {
      width2px;
      height3000px;
      positionabsolute;
      left600px;
      top0px;
    /*   visibility: hidden; */
      background-color#777;
    }
     
            
        </style>
    </head>
    <body>
        <div class="box a">a</div>
        <div class="box b">b</div>
     
        <div class="box c">c</div>
        
        
     
        <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.7.1/gsap.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.7.1/ScrollTrigger.min.js"></script>
        <script>
          
    // You can use a ScrollTrigger in a tween or timeline
    gsap.to(".b", {
      x: 400,
      rotation: 360,
      scrollTrigger: {
        trigger: ".b",
        start: "top center",
        end: "top 100px",
        scrub: true,
        markers: true,
        id: "scrub"
      }
    });
     
    // this is the helper function that sets it all up. Pass in the content <div> and then the wrapping viewport <div> (can be the elements or selector text). It also sets the default "scroller" to the content so you don't have to do that on all your ScrollTriggers.
        function smoothScroll(contentviewportsmoothness) {
      content = gsap.utils.toArray(content)[0];
      smoothness = smoothness || 1;
     
      gsap.set(viewport || content.parentNode, {overflow: "hidden"position: "fixed"height: "100%"width: "100%"top: 0left: 0right: 0bottom: 0});
      gsap.set(content, {overflow: "visible"width: "100%"});
     
      let getProp = gsap.getProperty(content),
        setProp = gsap.quickSetter(content"y""px"),
        setScroll = ScrollTrigger.getScrollFunc(window),
        removeScroll = () => content.style.overflow = "visible",
        killScrub = trigger => {
          let scrub = trigger.getTween ? trigger.getTween() : gsap.getTweensOf(trigger.animation)[0]; // getTween() was added in 3.6.2
          scrub && scrub.kill();
          trigger.animation.progress(trigger.progress);
        },
        heightisProxyScrolling;
     
      function onResize() {
        height = content.clientHeight;
        content.style.overflow = "visible"
        document.body.style.height = height + "px";
      }
      onResize();
      ScrollTrigger.addEventListener("refreshInit"onResize);
      ScrollTrigger.addEventListener("refresh", () => {
        removeScroll();
        requestAnimationFrame(removeScroll);
      })
      ScrollTrigger.defaults({scroller: content});
      ScrollTrigger.prototype.update = p => p// works around an issue in ScrollTrigger 3.6.1 and earlier (fixed in 3.6.2, so this line could be deleted if you're using 3.6.2 or later)
     
      ScrollTrigger.scrollerProxy(content, {
        scrollTop(value) {
          if (arguments.length) {
            isProxyScrolling = true// otherwise, if snapping was applied (or anything that attempted to SET the scroll proxy's scroll position), we'd set the scroll here which would then (on the next tick) update the content tween/ScrollTrigger which would try to smoothly animate to that new value, thus the scrub tween would impede the progress. So we use this flag to respond accordingly in the ScrollTrigger's onUpdate and effectively force the scrub to its end immediately.
            setProp(-value);
            setScroll(value);
            return;
          }
          return -getProp("y");
        },
        getBoundingClientRect() {
          return {top: 0left: 0width: window.innerWidthheight: window.innerHeight};
        }
      });
     
      return ScrollTrigger.create({
        animation: gsap.fromTo(content, {y:0}, {
          y: () => document.documentElement.clientHeight - height,
          ease: "none",
          onUpdate: ScrollTrigger.update
        }),
        scroller: window,
        invalidateOnRefresh: true,
        start: 0,
        end: () => height - document.documentElement.clientHeight,
        scrub: smoothness,
        onUpdate: self => {
          if (isProxyScrolling) {
            killScrub(self);
            isProxyScrolling = false;
          }
        },
        onRefresh: killScrub // when the screen resizes, we just want the animation to immediately go to the appropriate spot rather than animating there, so basically kill the scrub.
      });
    }
     
    // for a horizontal version, see https://codepen.io/GreenSock/pen/rNmQPpa?editors=0010



     
        </script>    
    </body>
    </html>
  2. Hello, I just grab the code from smooth scrolling doc and tried but its not working please give me solution...

     

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Scrolling</title>
        <style>
    .box.active {
      background-colorblue;
    }




     
    body {
      background-color#111;
      background-image:
        linear-gradient(rgba(255,255,255,.072pxtransparent 2px),
        linear-gradient(90degrgba(255,255,255,.072pxtransparent 2px),
        linear-gradient(rgba(255,255,255,.061pxtransparent 1px),
        linear-gradient(90degrgba(255,255,255,.061pxtransparent 1px);
      background-size100px 100px100px 100px20px 20px20px 20px;
      background-position-2px -2px-2px -2px-1px -1px-1px -1px;
    }
     
    .box {
      width100px;
      height100px;
      background-color#28a92b;
      positionabsolute;
      left100px;
      z-index100;
      line-height100px;
      font-size50px;
      text-aligncenter;
    }
     
    .a {
      top200px;
      background-color#8d3dae;
    }
     
    .b {
      top600px;
    }
     
    .c {
      top1000px;
      background-color#e26c16;
    }
     
    .ghost {
      top1000px;
      background-color#444;
    }
     
    .line {
      width2px;
      height3000px;
      positionabsolute;
      left600px;
      top0px;
    /*   visibility: hidden; */
      background-color#777;
    }
     
            
        </style>
    </head>
    <body>
        <div class="box a">a</div>
        <div class="box b">b</div>
     
        <div class="box c">c</div>
        
        
     
        <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.7.1/gsap.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.7.1/ScrollTrigger.min.js"></script>
        <script>
    // Smooth scroll setup
    const bodyScrollBar = Scrollbar.init(document.body, { damping: 0.1delegateTo: document });
     
    bodyScrollBar.setPosition(00);
    bodyScrollBar.track.xAxis.element.remove();
     
    // How to get them to work together
    ScrollTrigger.scrollerProxy("body", {
      scrollTop(value) {
        if (arguments.length) {
          bodyScrollBar.scrollTop = value;
        }
        return bodyScrollBar.scrollTop;
      }
    });
          
    // You can use a ScrollTrigger in a tween or timeline
    gsap.to(".b", {
      x: 400,
      rotation: 360,
      scrollTrigger: {
        trigger: ".b",
        start: "top center",
        end: "top 100px",
        scrub: true,
        markers: true,
        id: "scrub"
      }
    });
     
        </script>    
    </body>
    </html>
  3. Hello,

     

    I have one timeline animation and below there is scrollTrigger code also.. when i remove rimeline animation code then markers are placed correct pn trigger element but when i place timeline code back then scroll marker showing above the trigger element..dont know why? i have pasted my code below 
     

    // slider animation timeline
    gsap.timeline()
    .from(".header",{height:0duration:1.5ease:"back"})
    .from(".sliderText",{scale:1.5duration:1ease:"back"opacity:0},"<.5")
    .from(".smallIsland",{scale:.1duration:1ease:"back"opacity:0},"<.5")
    .to(".smallIsland",{y:15repeat:-1duration:3yoyo:true},"<.5")
    .from(".gramedisland",{scale:.1duration:1ease:"back"opacity:0},"<.5")
    .to(".gramedisland",{y:20repeat:-1duration:3yoyo:true},"<.5")
    .from(".waterFlow",{duration:1ease:"back"opacity:0},"<.5")
    .from(".plane",{x:300duration:1ease:"back"opacity:0},"<.5")
    .from(".nav",{y:-100duration:1ease:"back"opacity:0})
    .fromTo(".stone",{opacity:0},{duration:1opacity:1},"<.5")
    .to(".stone",{duration:3y:150rotate:30repeat:-1scale:.8},"<.5")
    .to(".plane",{y:15rotation:-5repeat:-1duration:3yoyo:true},"<.5");
     
    // scrolling effect
    let featureWidth = gsap.getProperty(".featuredBox""width");    
    gsap.from(".featuredBox",{
        x:featureWidth,
        duration:3,
        scrollTrigger:{
            trigger:".featuredBox",
            markers:true,
            start:"top center",
            end:"bottom center"
        }    
        });


     
×
×
  • Create New...