Jump to content
GreenSock

Search the Community

Showing results for 'overwrite'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • GreenSock Forums
    • GSAP
    • Banner Animation
    • Jobs & Freelance
  • Flash / ActionScript Archive
    • GSAP (Flash)
    • Loading (Flash)
    • TransformManager (Flash)

Product Groups

  • Club GreenSock
  • TransformManager
  • Supercharge

Categories

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Personal Website


Twitter


CodePen


Company Website


Location


Interests

  1. Hello @amitr95 I think the problems you are having might just be related to the general processing of the code's logic you run inside your function, and not really to GSAP measuring the height incorrectly. Here is an approach, that is a bit different on the logic side of things, which works fine for me with regard to the height. I also added overwrite: 'auto' to the tweens, so GSAP can sort out conflicting tweens that might be created along the way. [Note: this approach is not meant to be 100% bullet-proof. It is mainly to show, that the height gets tweened to the proper value.] https://codepen.io/akapowl/pen/VwBqJmj Edit: Since getting the logic right for something like this can become a bit tricky, here's another example of your setup, using an approach by OSUBlake - which works a lot better. Hope that will help. https://codepen.io/akapowl/pen/BaPvXQM Based on this demo. https://codepen.io/osublake/pen/JYQqZr
  2. I'm not completely sure what you're asking. But I think your problem is that you have one element that is controlled by two ScrollTriggers and they will fight for control if the first one is not yet done and the other one is starting, so you either have to make sure the other one is done when the next one starts or make it one big ScrollTrigger that just triggers over the whole duration (this seems like the easiest solution) https://codepen.io/mvaneijgen/pen/GRBPbgr?editors=1010 You could also look in to the overwrite property https://greensock.com/docs/v3/GSAP/Tween/vars If true, all tweens of the same targets will be killed immediately regardless of what properties they affect. If "auto", when the tween renders for the first time it hunt down any conflicts in active animations (animating the same properties of the same targets) and kill only those parts of the other tweens. Non-conflicting parts remain intact. If false, no overwriting strategies will be employed. Default: false.
  3. I'm using GSAP to manipulate an SVG map. See pen, based on @OSUblakes fine work with this pen I'd like to be able to maintain the map's position following a page refresh or ajax call for updated content. The whole SVG content will change although the bounds will not - the change would be in the icons. I've already attempted to save what I think might be useful in sessionStorage but get errors storing the object data. It doesn't help that I'm not a JavaScript man, as might be obvious with the following code that spits out it's dummy at the point of storing object with TypeError: cyclic object value Is what I'm trying to do possible, and if so, how? function initMapAnimation() { //sessionStorage.clear(); console.clear(); gsap.defaults({ ease: "power2.in", duration: .1, overwrite: "auto" }) //gsap.registerPlugin(Draggable, InertiaPlugin); var svg = document.querySelector("#map"); var reset = document.querySelector("#reset"); var pivot = document.querySelector("#pivot"); var proxy = document.createElement("div"); var viewport = document.querySelector("#viewport"); var ptzTrigger = document.querySelector("#site"); //var ptzTrigger = document.querySelectorAll('g:not(.clickable)'); var hasSavedValues = true; var rotateThreshold = 4; var reachedThreshold = false; var point = svg.createSVGPoint(); var startClient = svg.createSVGPoint(); var startGlobal = svg.createSVGPoint(); var viewBox = svg.viewBox.baseVal; var cachedViewBox = { x: viewBox.x, y: viewBox.y, width: viewBox.width, height: viewBox.height }; var zoom = { duration: 0.5, animation: new gsap.timeline(), scaleFactor: 1.6, ease: Power2.easeOut, }; gsap.set(pivot, { scale: 0 }); var resetAnimation = new gsap.timeline(); if (sessionStorage.getItem("resetAnimation") != null) { hasSavedValues = false; resetAnimation = JSON.parse(sessionStorage.getItem("resetAnimation") || "[]"); } var pivotAnimation = gsap.to(pivot, { duration: 0.1, alpha: 1, scale: 1, paused: true, }); var draggedSvg = Draggable.create(proxy, { throwResistance: 3000, minimumMovement: 10, trigger: ptzTrigger, throwProps: true, onPress: selectDraggable, onDrag: updateViewBox, onThrowUpdate: updateViewBox, onClick: function () { console.log("clicked"); }, dragClickables: false, }); if (sessionStorage.getItem("draggedSvg") != null) { hasSavedValues = false; draggedSvg = JSON.parse(sessionStorage.getItem("draggedSvg") || "[]"); } var rotatedSvg = Draggable.create(viewport, { type: "rotation", trigger: ptzTrigger, throwProps: true, liveSnap: true, snap: checkThreshold, onPress: selectDraggable, onClick: function () { console.log("clicked"); }, dragClickables: false, }); if (sessionStorage.getItem("rotatedSvg") != null) { hasSavedValues = false; rotatedSvg = JSON.parse(sessionStorage.getItem("rotatedSvg") || "[]"); } rotatedSvg[0].disable(); reset.addEventListener("click", resetViewport); window.addEventListener("wheel", onWheel, { passive: false }); window.addEventListener("resize", function () { pivotAnimation.reverse(); }); window.addEventListener("contextmenu", function (event) { event.preventDefault(); event.stopPropagation(); return false; }); // // INITIALISE VIEWPORT // =========================================================================== if (hasSavedValues == false) { resetAnimation.to(viewport, { duration: 0, attr: { transform: "matrix(1,0,0,1,0,0)" }, // rotation: "0_short", smoothOrigin: true, svgOrigin: "0 0", ease: Power3.easeOut }, 0); } // // ON WHEEL // =========================================================================== function onWheel(event) { event.preventDefault(); event.stopPropagation(); stopUpdateTimer(); pivotAnimation.reverse(); var normalized; var delta = event.wheelDelta; if (delta) { //console.log("FWD"); normalized = (delta % 120) == 0 ? delta / 120 : delta / 12; } else { //console.log("REV"); delta = event.deltaY || event.detail || 0; normalized = -(delta % 3 ? delta * 10 : delta / 3); } var scaleDelta = normalized > 0 ? 1 / zoom.scaleFactor : zoom.scaleFactor; point.x = event.clientX; point.y = event.clientY; var startPoint = point.matrixTransform(svg.getScreenCTM().inverse()); var fromVars = { duration: zoom.duration, ease: zoom.ease, x: viewBox.x, y: viewBox.y, width: viewBox.width, height: viewBox.height, }; viewBox.x -= (startPoint.x - viewBox.x) * (scaleDelta - 1); viewBox.y -= (startPoint.y - viewBox.y) * (scaleDelta - 1); viewBox.width *= scaleDelta; viewBox.height *= scaleDelta; zoom.animation = gsap.from(viewBox, fromVars); //console.log(fromVars); } // // SELECT DRAGGABLE // =========================================================================== function selectDraggable(event) { stopUpdateTimer(); if (resetAnimation.isActive()) { resetAnimation.kill(); } startClient.x = this.pointerX; startClient.y = this.pointerY; startGlobal = startClient.matrixTransform(svg.getScreenCTM().inverse()); // Right mouse button if (event.button === 2) { reachedThreshold = false; gsap.set(viewport, { svgOrigin: startGlobal.x + " " + startGlobal.y }); gsap.set(pivot, { x: this.pointerX, y: this.pointerY }); draggedSvg[0].disable(); rotatedSvg[0].enable().update().startDrag(event); pivotAnimation.play(0); } else { gsap.set(proxy, { x: this.pointerX, y: this.pointerY }); rotatedSvg[0].disable(); draggedSvg[0].enable().update().startDrag(event); pivotAnimation.reverse(); } sessionStorage.setItem("resetAnimation", JSON.stringify(resetAnimation)); sessionStorage.setItem("draggedSvg", JSON.stringify(draggedSvg)); sessionStorage.setItem("rotatedSvg", JSON.stringify(rotatedSvg)); } // // RESET VIEWPORT // =========================================================================== function resetViewport() { var resetDuration = 1.5; var ease = Power3.easeOut; pivotAnimation.reverse(); if (draggedSvg[0].tween) { draggedSvg[0].tween.kill(); } if (rotatedSvg[0].tween) { rotatedSvg[0].tween.kill(); } console.log(resetAnimation); resetAnimation.clear() .to(viewBox, { duration: resetDuration, x: cachedViewBox.x, y: cachedViewBox.y, width: cachedViewBox.width, height: cachedViewBox.height, ease: ease },) .to(viewport, { duration: resetDuration, attr: { transform: "matrix(1,0,0,1,0,0)" }, // rotation: "0_short", smoothOrigin: true, svgOrigin: "0 0", ease: ease }, 0); startUpdateTimer(); sessionStorage.setItem("resetAnimation", JSON.stringify(resetAnimation)); sessionStorage.setItem("draggedSvg", JSON.stringify(draggedSvg)); sessionStorage.setItem("rotatedSvg", JSON.stringify(rotatedSvg)); } // // CHECK THRESHOLD // =========================================================================== function checkThreshold(value) { if (reachedThreshold) { return value; } var dx = Math.abs(this.pointerX - startClient.x); var dy = Math.abs(this.pointerY - startClient.y); if (dx > rotateThreshold || dy > rotateThreshold || this.isThrowing) { reachedThreshold = true; return value; } return this.rotation; } // // UPDATE VIEWBOX // =========================================================================== function updateViewBox() { if (zoom.animation.isActive()) { return; } point.x = this.x; point.y = this.y; var moveGlobal = point.matrixTransform(svg.getScreenCTM().inverse()); viewBox.x -= (moveGlobal.x - startGlobal.x); viewBox.y -= (moveGlobal.y - startGlobal.y); sessionStorage.setItem("resetAnimation", JSON.stringify(resetAnimation)); sessionStorage.setItem("draggedSvg", JSON.stringify(draggedSvg)); sessionStorage.setItem("rotatedSvg", JSON.stringify(rotatedSvg)); } }
  4. Well, as with everything, the devil is in the detail, which is why it is very hard to give general recommendations for a more complex scenario like yours. Since you are concerned about things not working when reloading the page when it's scrolled down, you might want to reconsider the general approach of how you implement the change of the backgroundColor, too, because the way you are doing it in the demos you posted, things will not work as you might intend in that case. One logical problem is the following: You are changing the playstate of pre-built timelines with.to() tweens in callbacks of ScrollTriggers, when the page is loaded at the very bottom, ScrollTrigger will make sure that those callbacks get called. So now you have multiple tweens being called quickly one after the other, which are all tweening on the same property of the same element, so you are creating conflicting tweens. When you scroll back up then, the .to() tween is supposed to be reversed, but it will probably reverse back to the color that it was at the time when that tween was being created - which very likely is not the color you'd expect but some value of a color in between all those colors. Creating your tweens upfront can be quite the tricky scenario to begin with, when you are going to tween on the same property of the same element with multiple different instances. So one way you could prevent all those logical hurdles, would be to create the tweens in the callbacks directly instead of pre-building them. Then you could either use .fromTo() tweens to make sure you always tween from one specific color to another specific color, when the callback runs, or .to() tweens with overwrite set to 'auto' to prevent conflicts I mentioned above. In this pen with the lottie-scrolltriggers handling the pinning themselves, things seem to work fine even if I create those ScrollTriggers before all the lottie-scrolltriggers, but your mileage may vary. https://codepen.io/akapowl/pen/gOjKLqy
  5. Hi, i'm not exactly sure what effect you are going for. FWIW it seems a bit disorienting to move something down to a y:200 while scrolling up. That aside I would avoid creating 2 timelines initially time that control the same properties of the same thing. To avoid conflicts I would suggest creating these animations fresh when you need them inside your callbacks sort of like: ScrollTrigger.create({ trigger: ".top-page", start: "top-=100 top", end: "top+=200 top", markers: true, onEnter: () => {let tl1 = gsap.timeline({}) .fromTo("header", { y: 0, overwrite: 'auto' },{ duration: 2, y: 200, ease: CustomEase.create("custom", "0.5, 0, 0, 1"), overwrite: 'auto' })}, onLeaveBack: () => {let tl2 = gsap.timeline({}) .to("header", { scale: 1.2, y: 200, }) .set("header", {y: 200,scale: 1,},"hide") .to("header", {opacity:1},"start2") .to(("header"), { y: 0, duration: 1, ease: "power4.out" }, "start2")} }); I would also remove locomotive scroll until you know things are working fine without it. Hopefully this set up will allow you to remove some of redundancy between the 2 animations like tweening and setting y:200 multiple times. If you need more help please try to simplify the animations as much as possible in a fork of the original pen.
  6. I got animation like in the video attached that is triggered via the code below: // tab is the html div object of the clicked tab button // blue line is the html div object of the line below the buttons gsap.to( blueLine, { duration: 0.5, left: tab.offsetLeft, width: tab.offsetWidth, overwrite: false, lazy: false } ) As you can see on the video it looks like gsap is resetting the "left" property to 0 and animates it from there. Is there a way to not reset the value and instead animate from the current property value? I couldn't find anything about it in the docs or forum. Screen Recording 2023-01-24 at 00.43.10.mov
  7. Hi In my codepen example, when mouse enters the red area, I start 5 tweens, one on each grey bar in the green area. When mouse leaves the red area, I kill all the tweens. Each bar is supposed to grow/shrink to a random value (height css prop), and then when it's finished, repeat this to another random value. It is working almost correctly. The only thing that bothers me is, when you leave the mouse in for a few iterations, sometimes a tween will randomly change his From value before going to his To value. This is making some of the bars randomly "jumping". I am using repeatRefresh: true, and from what I understand, it is supposed to force the next loop using current values as From values. So why are some of these animations still "jumping"? I also tried to use immediateRender: true and overwrite: true, but it changed nothing. Any idea?
  8. I saw a few problems: You're setting the width/height in the same gsap.set() call as the transformOrigin, and in this very rare edge case that's actually a problem because it just so happens that in the for...in loop through the properties, transformOrigin happens BEFORE the width/height. So when it tries to calculate the percentage-based origin offsets, your <rect> literally has no width or height at all, thus it gets positioned in its upper left corner. The solution: set the width/height FIRST. You could just separate those out into their own gsap.set() that you put first. You're creating conflicting animations. If you click again before the first set of animations completely finishes their 4 repeats, you'll be creating new ones that are also fighting with the old ones for control of the same elements. Make sure you kill() the old animations before you create new ones. Or you can just leverage the overwrite feature (overwrite: true here). Just so you know, the smoothOrigin does absolutely nothing in this line: gsap.timeline({ smoothOrigin: true, yoyo: false, repeat: 4 }); Timelines don't have a property like that. Maybe you intended to pass that down as a default for all child tweens?: gsap.timeline({ defaults: {smoothOrigin: true}, yoyo: false, repeat: 4 }); https://codepen.io/GreenSock/pen/NWBaLOd?editors=0010 Does that clear things up?
  9. Right here: gsap.utils.toArray("#menu a").forEach(el => { let linkTo = document.querySelector(el.getAttribute("data-link")), st = ScrollTrigger.create({trigger: linkTo, start: "top top"}); // create a ScrollTrigger just to track the location of the linkTo element, including pinning, etc. el.addEventListener("click", event => { event.preventDefault(); // don't let the browser jump to the link gsap.set("body", {overflow: "scroll"}); gsap.to(window, {scrollTo: st.start, overwrite: "auto"}); }); }); Jack is creating a ScrollTrigger instance for each section and then getting the start value of that particular ScrollTrigger instance. Finally it passed that to the ScrollTo plugin which creates the scroll animation. I updated the codepen example in order to close the menu as well: https://codepen.io/GreenSock/pen/MWBvVKa Let us know if you have more questions. Happy Tweening!
  10. Hi @aileen-r and welcome to the GreenSock forums! The reason for the different speed is beacuse you're setting the timescale of each animation on the mouse leave event to be 2 and is never reset to 1, that's why is faster after the first mouse over event. If you want to keep the same speed on both events just remove that and make the duration of the animation half the current time: reactions.forEach(reaction => { const action = gsap.to( reaction, { scale: 1.2, margin: '0 30px 0 20px', duration: 0.25, ease: 'power2.inOut', overwrite: 'true', paused: true } ); reaction.addEventListener("mouseenter", function() { action.play(0); }); reaction.addEventListener("mouseleave", function() { action.reverse(); }); }); Now if you still want the leave animation to be faster, then keep the timescale setter on the mouse leave, but add one to the mouse enter as well: reactions.forEach(reaction => { const action = gsap.to( reaction, { scale: 1.2, margin: '0 30px 0 20px', duration: 0.25, ease: 'power2.inOut', overwrite: 'true', paused: true } ); reaction.addEventListener("mouseenter", function() { action.timeScale(1).play(0); }); reaction.addEventListener("mouseleave", function() { action.timeScale(2).reverse(); }); }); You can learn more about timeScale here: https://greensock.com/docs/v3/GSAP/Tween/timeScale() Finally if you want to prevent the bounce effect in the reactions container, that's a bit more tricky since you need to get the current active element check in the array, see if there are elements before and move all those a specific amount of pixels and do the same for the elements after the active one. Finally when leaving the reactions container tween all the reactions back to their original x position. Avoid using margins for this if you can for that scenario. But I must say as a user I would be totally fine with the way things are, just speed up the animation and keep the timescale, no need to change it IMHO. Hopefully this helps. Let us know if you have more questions. Happy Tweening!
  11. Thanks for your further help @Rodrigo, I added overwrite, and it seems that the bubbling is stopped, but it still doesn't work correctly. When I scroll, sometimes it works but sometimes does not. How it doesn't work is that the scroll goes to the next panel and back. https://codepen.io/haruka1234/pen/eYjgGvW?editors=1010
  12. Hi @Haribo, Yeah I see the issue. It seems that adding overwrite into the onLeave an onLeaveBack scroll tweens seems to fix the problem: onLeave: () => { if (i !== panels.length - 1) { let nextPanelId = `panel-${i + 1}`; gsap.to(window, { overwrite: true, scrollTo: { y: ScrollTrigger.getById(nextPanelId).start + 1, autoKill: false }, }); } }, onLeaveBack: () => { if (i) { let prevPanelId = `panel-${i - 1}`; gsap.to(window, { overwrite: true, scrollTo: { y: ScrollTrigger.getById(prevPanelId).end - 1, }, }); } }, From the DOCS (https://greensock.com/docs/v3/GSAP/Tween/vars) : overwrite If true, all tweens of the same targets will be killed immediately regardless of what properties they affect. If "auto", when the tween renders for the first time it hunt down any conflicts in active animations (animating the same properties of the same targets) and kill only those parts of the other tweens. Non-conflicting parts remain intact. If false, no overwriting strategies will be employed. Default: false. Hopefully this helps. Let us know if you have more questions. Happy Tweening!
  13. Hi, This should work: const roll1 = roll(".rollingText", {duration: 10}), roll2 = roll(".rollingText02", {duration: 10}, true), scroll = ScrollTrigger.create({ onUpdate(self) { if (self.direction !== direction) { direction *= -1; roll1.timeScale(direction * 3); roll2.timeScale(direction * 3); gsap.to([roll1, roll2], {timeScale: direction, overwrite: true, duration: 1}); } } }); Happy Tweening!
  14. The live example you have and the demo you provided don't use either Draggable or the Inertia Plugin, so you can set the draggable option to false: let carousel = buildCarousel(items, { radiusX: 250, radiusY: 210, activeAngle: -90, draggable: false, onClick(element, self) { self.to(element, {duration: 1, ease: "power1.inOut"}, "short"); }, onActivate(element, self) { element.classList.add("active"); }, onDeactivate(element, self) { element.classList.remove("active"); }, // when a drag or animation starts (via the Carousel's to()/next()/previous() methods) onStart(element, self) { gsap.to(descriptions[items.indexOf(element)], {autoAlpha: 0, duration: 0.25, overwrite: "auto"}); }, onStop(element, self) { gsap.to(descriptions[items.indexOf(element)], {autoAlpha: 1, overwrite: "auto"}); } }); If you want to use the example with the red circles you can just offset the start and endpoints by minus 25%: gsap.set(items, { motionPath: { path: circlePath, align: circlePath, alignOrigin: [0.5, 0.5], start: -0.25, end: i => (i / items.length) - 0.25, }, scale: 0.9 }); The rest of the code should remain the same. Yet another option with the latter example (red dots) is to set the start point of the path to the top of the circle. Check this article by @PointC https://www.motiontricks.com/cut-your-path-start-points-in-adobe-illustrator/ Hopefully this helps. Happy Tweening!
  15. Hey, folks! My team over at The DataFace has this nifty Svelte action powered by GSAP that we've been using for the past few projects. It blends a few approaches that we've seen in the forums. I thought we'd share the wealth with a few key examples in this repl. We have a more complex version that handles timeline positioning that I can share once it's refined. import { gsap } from 'gsap'; import { ScrollTrigger } from 'gsap/ScrollTrigger' gsap.registerPlugin(ScrollTrigger); export default (node, { type, children, scrollTrigger, ...args }) => { let targets = children ? node.children : node; let timelineArgs = scrollTrigger ? { scrollTrigger: { trigger: node, start: 'top center', ...scrollTrigger } } : {}; let timeline = gsap.timeline(timelineArgs)[type](targets, { ease: 'power2.out', overwrite: true, ...args }); return { update(params) { timeline.duration(params.duration); }, destroy() { timeline.killTweensOf(targets); } } };
  16. Hi, The issue is not really about overwritting, that's a completely different situation. Basically what's happening here is that you have different event handlers battling for control to play/reverse the same GSAP instance, nothing more. A simple boolean and some conditional logic seems to solve the issue, in order to prevent ScrollTrigger's update callback from controlling the instance: https://codepen.io/GreenSock/pen/Yzvdpog Here you can read more about overwrite: https://greensock.com/docs/v3/GSAP/Tween/vars Let us know if you have more questions. Happy Tweening!
  17. Hi Everyone! I have a timeline that plays and reverses based on scroll direction. I also use a mouse enter/leave function to trigger/control the same timeline. When using ScrollSmoother the direction overrides the mouse enter/leave functions (the timeline won't play until the scroll is at rest, even when I trigger mouse enter/leave events). My question: Can I overwrite the scroll control to prioritize the "mouse enter/leave" functions? Thanks, as always.
  18. Hi @Fabian W and welcome to the GreenSock forums! First thanks for being a Club GreenSock member and supporting GSAP! 🥳 What you are looking for is the invalidateOnRefresh configuration option in the ScrollTrigger configuration object: Boolean - If true, the animation associated with the ScrollTrigger will have its invalidate() method called whenever a refresh() occurs (typically on resize). This flushes out any internally-recorded starting values. https://greensock.com/docs/v3/GSAP/Tween/invalidate() This seems to work the way you intend: let t1 = gsap.to(c1, { scrollTrigger: { scrub: true, start: () => 0, end: () => 'max', markers: true, invalidateOnRefresh: true,// <- HERE }, y: () => document.body.clientHeight - c1.clientHeight, ease: 'none', overwrite: 'auto' }); let t2 = gsap.to(c2, { scrollTrigger: { scrub: true, start: () => 0, end: () => 'max', markers: true, invalidateOnRefresh: true,// <- HERE }, y: () => document.body.clientHeight - c2.clientHeight, ease: 'none', overwrite: 'auto' }); Hopefully this helps. If you have more questions let us know. Happy Tweening!
  19. I'm not entirely sure how you want it to work, but it may be as simple as: ScrollTrigger.create({ trigger: el, start: 'top 50%', end: (self) => '+=' + el.offsetHeight, onToggle: (self) => { if (self.isActive) { gsap.to('body', { backgroundColor: color || 'transparent', duration: 0.6, overwrite: 'auto', }); } }, }); The way it was set up in Rodrigo's demo made the ScrollTriggers overlap which would cause the tweens to fight with each other during the overlaps.
  20. Hi @eliphino and welcome to the GreenSock forums! First, thank you for being a Club GreenSock member and supporting GreenSock! 🥳 I think this approach works better, since you are also adding the event listener to the window object on every loop: window.addEventListener("mousemove", e => { gsap.to(targets, { duration: 0.35, x: e.pageX, y: e.pageY, ease: "none", overwrite: "auto", stagger: 0.035, }); }); Also I'd recommend you to use less elements, since adding a bunch of them tends to look a bit off, but I'll leave that to your better judgement and the needs of your project. Let us know if you have more questions. Happy Tweening!
  21. If you want to overwrite the default scroll behavior of the browser you'll need to have a clear goal with it and know what you're doing. If you do not have this or you are new to coding I would not recommend doing this. ScrollTrigger taps in the to default scroll behavior. If you have some other element you want to use as the scroll container you can define a scroller (see the docs https://greensock.com/docs/v3/Plugins/ScrollTrigger) String | Element - By default, the scroller is the viewport itself, but if you'd like to add a ScrollTrigger to a scrollable <div>, for example, just define that as the scroller. You can use selector text like "#elementID" or the element itself. If you instead just want to watch for the scroll event you can also use the Observer plugin https://greensock.com/docs/v3/Plugins/Observer Instead of showing the issue you're having can you maybe explain what your goal is? If we know what it is you want to do it will be easier to help you with an appropriate solution.
  22. Hi @Rodrigo, Thank you for your detailed answer! All clear. I finally managed to do it but without using the snap functionality, cause I needed to scroll up and down. The solution was based on another example found on the forum by @ZachSaucier (the codepen : https://codepen.io/GreenSock/pen/NWxNEwY , and the thread: Here is the (a) solution : let panels = gsap.utils.toArray('.block-scroll'), scrollTween; function goToSection(i) { scrollTween = gsap.to(window, { scrollTo: {y: i * innerHeight, autoKill: false}, duration: 1, ease: Power3. easeOut, onComplete: () => scrollTween = null, overwrite: true }); } panels.forEach((panel, i) => { ScrollTrigger.create({ //markers: true, trigger: panel, start: 'top 75%', end: 'top 25%', onEnter: self => { self.isActive && !scrollTween && goToSection(i+1); console.log(panel); }, onEnterBack: self => { self.isActive && !scrollTween && goToSection(i); } }); }); Anyway, thanks for your quick answer.
  23. @Rodrigo - I truly appreciate your detailed explanation. Everything you said makes sense and speaks to the core of the issue that I was facing. I was not aware of the overwrite property, so that was super helpful as well. I believe I'll be able to come up with a good solution based on your feedback. Thanks again for your time and knowledge!!
  24. Hi, The issue with overwrites is basically generated when one or more GSAP instances affect the same property (blur filter in this case), on the same element at the same time. Right now you are creating two different animations for each element before even running one of them. On top of that you are not correctly reversing all the animations, for example you move from heading-2 to heading-3. When you enter heading-2 the heading-1 element gets affected by one animation, when you move to heading-3, one heading-1 animation is reversed but as soon as you enter heading-3 another one starts while the other is still reversing. You have two different animations affecting the same property on the same element. On top of that overwrite won't help you in this case, you can test it by using this configuration in your methods: function animation_blur(elem) { const theAnimation = gsap.timeline(); gsap.set(elem, { filter: 'blur(0px)' }); theAnimation.to(elem, { filter: 'blur(5PX)', ease: 'none', duration: 0.5, overwrite: true, }); return theAnimation } function animation_blur2(elem) { const theAnimation = gsap.timeline(); gsap.set(elem, { filter: 'blur(0px)' }); theAnimation.to(elem, { filter: 'blur(20PX)', ease: 'none', duration: 0.5, overwrite: true, }); return theAnimation } You'll notice that this definitely doesn't work the way you want. Here is what overwrite does: If true, all tweens of the same targets will be killed immediately regardless of what properties they affect. If "auto", when the tween renders for the first time it hunt down any conflicts in active animations (animating the same properties of the same targets) and kill only those parts of the other tweens. Non-conflicting parts remain intact. If false, no overwriting strategies will be employed. Default: false. Since your animations affect just one property everything will be flushed out and only the animations created by the animation_blur2 method will remain and work, that's why I think the best approach is the one I suggested, as that takes the element from it's current state to the state you want (no blur, low blur or high blur). If you need to use reverse, that means that you are using an event handler for doing that, so why using a method that creates a new GSAP instance is not an option? If you want to keep the current approach you have, you have to look into reversing everything and then playing the instances you want, but you already ran into some logic issues with your code. Based on the Codepen example you gave us I provided a solution for the issue I saw there which should be scalable into a larger setup without too much problems. If you keep having issues, let us know. Happy Tweening!
  25. Hey @Rodrigo - thanks for your response! I appreciate the new approach that you suggested, but I am looking for a solution that still uses .reverse() on mouseleave. (My original codepen is kind of a boiled down example of something more complicated that I'm working on). You mentioned that I'm running into "overwrite issues" - do you think that this is the core issue that I'm facing in my original codepen? Could you possibly expand on overwrite issues? Is there any documentation on overwrite issues? Any ways to combat overwrite issues from occurring? Thanks again!
×