Jump to content
Search Community

SagarSurendhrababu

Members
  • Posts

    6
  • Joined

  • Last visited

Everything 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-color: blue; } body { background-color: #111; background-image: linear-gradient(rgba(255,255,255,.07) 2px, transparent 2px), linear-gradient(90deg, rgba(255,255,255,.07) 2px, transparent 2px), linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px); background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px; background-position: -2px -2px, -2px -2px, -1px -1px, -1px -1px; } .box { width: 100px; height: 100px; background-color: #28a92b; position: absolute; left: 100px; z-index: 100; line-height: 100px; font-size: 50px; text-align: center; } .a { top: 200px; background-color: #8d3dae; } .b { top: 600px; } .c { top: 1000px; background-color: #e26c16; } .ghost { top: 1000px; background-color: #444; } .line { width: 2px; height: 3000px; position: absolute; left: 600px; top: 0px; /* 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(content, viewport, smoothness) { content = gsap.utils.toArray(content)[0]; smoothness = smoothness || 1; gsap.set(viewport || content.parentNode, {overflow: "hidden", position: "fixed", height: "100%", width: "100%", top: 0, left: 0, right: 0, bottom: 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); }, height, isProxyScrolling; 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: 0, left: 0, width: window.innerWidth, height: 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. I went through this page .scrollerProxy() documentation page but the video didn't make sense to me so I need support about smooth scrolling GSAP code.. I did grab code from Demo (native ScrollTrigger) but its not working. Here i am struggling to understand its concept and code
  3. 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-color: blue; } body { background-color: #111; background-image: linear-gradient(rgba(255,255,255,.07) 2px, transparent 2px), linear-gradient(90deg, rgba(255,255,255,.07) 2px, transparent 2px), linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px); background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px; background-position: -2px -2px, -2px -2px, -1px -1px, -1px -1px; } .box { width: 100px; height: 100px; background-color: #28a92b; position: absolute; left: 100px; z-index: 100; line-height: 100px; font-size: 50px; text-align: center; } .a { top: 200px; background-color: #8d3dae; } .b { top: 600px; } .c { top: 1000px; background-color: #e26c16; } .ghost { top: 1000px; background-color: #444; } .line { width: 2px; height: 3000px; position: absolute; left: 600px; top: 0px; /* 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.1, delegateTo: document }); bodyScrollBar.setPosition(0, 0); 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>
  4. Hello Akapowl, Instead of height I used "y" value. Now its working.. Thanks once again your instant support.. GSAP such a rocking stuff..
  5. Hello Akapowl, Your guess work was perfect.... i removed that tweening after that its working.. what property should I use for height ?
  6. 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:0, duration:1.5, ease:"back"}) .from(".sliderText",{scale:1.5, duration:1, ease:"back", opacity:0},"<.5") .from(".smallIsland",{scale:.1, duration:1, ease:"back", opacity:0},"<.5") .to(".smallIsland",{y:15, repeat:-1, duration:3, yoyo:true},"<.5") .from(".gramedisland",{scale:.1, duration:1, ease:"back", opacity:0},"<.5") .to(".gramedisland",{y:20, repeat:-1, duration:3, yoyo:true},"<.5") .from(".waterFlow",{duration:1, ease:"back", opacity:0},"<.5") .from(".plane",{x:300, duration:1, ease:"back", opacity:0},"<.5") .from(".nav",{y:-100, duration:1, ease:"back", opacity:0}) .fromTo(".stone",{opacity:0},{duration:1, opacity:1},"<.5") .to(".stone",{duration:3, y:150, rotate:30, repeat:-1, scale:.8},"<.5") .to(".plane",{y:15, rotation:-5, repeat:-1, duration:3, yoyo: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...