Jump to content
Search Community

Wemnia

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by Wemnia

  1. Thanks a lot for the answer! I was able to solve my problem, I improved my code and I learned new things.☺️
  2. Hi everyone, I've been trying to solve this problem for many hours, but I can't find a solution. I hope some of you can help me. Depending on the situation, I dynamically create a timeline to run when needed. Below I leave you an example code: let itemScrollTimeLine = gsap.timeline({ paused: true, onComplete: resetTimeline }); function resetTimeline() { console.log('Completed'); itemScrollTimeLine.clear(); } if (itemList.indexOf(elem.id) >= 0) { let elemPos = (window.innerHeight - document.getElementById(elem.id).offsetHeight) / 2; itemScrollTimeLine.add(gsap.to(window, { duration: 1.2, ease: "power1.inOut", scrollTo: { y: elem, offsetY: elemPos } })); } else { itemScrollTimeLine.add(gsap.to(window, { duration: 1.2, ease: "power1.inOut", scrollTo: { y: elem, offsetY: 100 } })); } itemScrollTimeLine.add(gsap.to(elem, { ease: "power3.inOut", duration: 0.8, '--line-color-top': '#a18248' }), '>'); // And so on.... When i click a button I start the timeline with the command itemScrollTimeLine.play(); . Depending on the button clicked (in the code it is saved in the "elem" variable) a scroll is carried out on a specific position on the page. If the buttons are clicked sequentially fast, however, there is a bad effect, and I'm trying to find a solution. I thought a solution would be to check if the animation is currently active, and if the scroll is running, stop it, and immediately complete the rest of the animations a jump effect upon immediate completion of the animation). This is the code I tried to write that I inserted as a control before creating a new timeline of the pressed key: if (itemScrollTimeLine.isActive()) { if (itemScrollTimeLine.progress() < 0.6) { itemScrollTimeLine.seek(1.2); let children = itemScrollTimeLine.getChildren(false, true, true); itemScrollTimeLine.remove(children[0]); } itemScrollTimeLine.progress(1); } I entered 0.6 as the progress value because the timeline has a total duration of 2 seconds and the scroll has a duration of 1.2 seconds. Unfortunately running this code I always have a jump effect to the immediate completion of the running timeline. Can you tell me a method to solve this annoying problem? Many thanks in advance!?
  3. Thanks a lot for the answer! I tried to update my CodePen following the example you linked to me. Now the circle has very little delay, and that's perfect! Further tips to improve my code are welcome!?
  4. Hello everybody, i am trying to create a custom cursor but i am having an animation delay problem. As you can see from the CodePen, I would like the cursor to be followed by two simple svg shapes. I added a listner that performs my animation function every time the mouse is moved. The movement delay of the larger circle is performed correctly, while I would like the smaller circle to follow the cursor without any delay. Unfortunately, however, by not inserting any delay, the small circle still moves with an annoying delay, and I can't figure out how to solve this problem. Can you help me? Code optimization tips are also welcome!
  5. Hello everybody, I have recently started using GSAP, and I am still inexperienced in using it. However, I am happy to have become part of this community! I am creating a page in which I would like to insert a smooth scroll snapping, and also use a smooth scroll for the navbar anchor links that lead to the various sections of the page. As you can see from my Pen I created, everything seems to work fine, but there are some problems that I can't solve: - If while scrolling in one direction with the mouse wheel, before the animation ends, I start to rotate the mouse wheel in the opposite direction, sometimes "jumps" will occur, towards the new section, instead of still perform a smooth scroll. - If I use the menu links to reach a section (obviously without using the mouse wheel), a strange error occurs and I am not taken to the correct section (this did not happen before implementing the scroll snapping system). Can you help me to solve these annoying problems? Tips are also welcome to make my JS code better and more performing.? Thank you!
×
×
  • Create New...