Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...

jenda

Members
  • Posts

    35
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

jenda's Achievements

  1. Hello, yes, you are right. Is there any possibility to pause and play a function I defined? I would like to do it for two mouse events - mouseenter (pause) and mouseleave (play) but I don't you any timeline now. I only found this command. I need it for the last example I posted here. I've achieved to stop the animation with following code. But after I call this function with my mouse and use the bulletpoints the animations get confused. What do I wrrong there? slideTextWrapper.addEventListener("mouseenter", function(){ timer.pause(); }) slideTextWrapper.addEventListener("mouseleave", function(){ timer.play(); }) I puted there 3 times. But I guess it would be possible to call just once, right? I can also see a little speed difference between the text and image animation. Shall I set there something else to let start and end both animation simultaneously? Here is my example again. https://codepen.io/jankout/pen/zYPgWyo?editors=0011
  2. Thank you for your response. Of course, I don't expect that somebody will do my work here. I need help with some things that don´t work propertly now. The bulletpoints navigation don't work correctly although I took the code from another example. I guess there is a problem with the infinite animation that's why navigation points don't know where the progress currently is. For this reason I took another example and adjusted. The navigation works there correctly. But I guess the code could be written more GSAP-like, isn't it? My open question is: How can I achieve to animate as soon as a slide comes into the view point or as soon as it will be slide? I guess I should use ScrollTrigger. Do I? https://codepen.io/jankout/pen/zYPgWyo
  3. Hello, thank you for your response. I created a codepen preview. My goal is to animate the text and number element separetly which already works. Additionaly, I would like to animate the content of the text block as soon as the parent text element comes into the viewport. The bulletpoints shall go to the right position. I guess there is something wrong why they don't show the right slide(s). The last goal I have is to start the animation as soon as the slider comes into the viewport - with help of ScrollTrigger. Could somebody give me some advices how to archive my goals. I think there are just few thinks to change but I stuck by now. https://codepen.io/jankout/pen/bGYOmad
  4. Hello, a question. How could I automatically add bullet points and link them to the right slide? I would like to use the bullet points as a navigation.
  5. Hello Cassie, I would like to animate two separate things at the same time - pictures (in your examples the numbered slides) and text (in my case). The animation effect is just vertical and shall happen at the same time. And I would like to start (onEnter) and stop (onLeave) the animation with help of ScrollTrigger. My question is - shall I put both in a timeline to get the right result or how can I achieve this goal? My code looks like this by now and it works so far but I'm sure that it's not the best-practice-one. 😊 In generall, I would like to know if I can make the code more best-practice-like. If you have any suggestion I would be happy to learn something new. Thank you. In my case I don't use any navigation for the slides - maybe I have to remove more from the original code like proxy settings? // Start page slider var sliderPictures = document.querySelectorAll('.section-background-overlay .section-background-overlay_background-image picture') var sliderTexts = document.querySelectorAll('.section-background-overlay .overlay .text-wrapper') var slideCont = document.querySelector(".section-background-overlay .overlay") var slideDelay = 5; var slideDuration = 1; var snapX; function heroSliderStart() { var progressWrap = gsap.utils.wrap(0, 1); var numSlidesPicture = sliderPictures.length; var numSlidesText = sliderTexts.length; gsap.set(sliderPictures, { yPercent: i => i * 100 }); gsap.set(sliderTexts, { yPercent: i => i * 100 }); var wrap = gsap.utils.wrap(-100, (numSlidesPicture - 1) * 100); var wrapText = gsap.utils.wrap(-100, (numSlidesText - 1) * 100); var timer = gsap.delayedCall(slideDelay, autoPlay); var animation = gsap.to(sliderPictures, { yPercent: "+=" + (numSlidesPicture * 100), paused: true, duration: 1, ease: "none", repeat: -1, modifiers: { yPercent: wrap } }) var animation2 = gsap.fromTo(sliderTexts, { autoAlpha: 1, paused: true, duration: 1, ease: "none", repeat: -1, }, { yPercent: "+=" + (numSlidesText * 100), autoAlpha: 1, paused: true, duration: 1, ease: "none", repeat: -1, modifiers: { yPercent: wrapText }, } ); var proxy = document.createElement("div"); var slideAnimation = gsap.to({}, {}); var slideWidth = 0; var wrapWidth = 0; resize(); window.addEventListener("resize", resize); slideCont.addEventListener("mouseenter", function() { timer.pause() }); slideCont.addEventListener("mouseleave", function() { timer.play() }); function animateSlides(direction) { timer.restart(true); slideAnimation.kill(); var x = snapX(gsap.getProperty(proxy, "x") + direction * slideWidth); slideAnimation = gsap.to(proxy, { x: x, duration: slideDuration, onUpdate: updateProgress }); } function autoPlay() { animateSlides(-1); } function updateProgress() { animation.progress(progressWrap(gsap.getProperty(proxy, "x") / wrapWidth)); animation2.progress(progressWrap(gsap.getProperty(proxy, "x") / wrapWidth)); } function resize() { var norm = (gsap.getProperty(proxy, "x") / wrapWidth) || 0; slideWidth = sliderPictures[0].offsetWidth; wrapWidth = slideWidth * numSlidesPicture; snapX = gsap.utils.snap(slideWidth); gsap.set(proxy, { x: norm * wrapWidth }); animateSlides(0); slideAnimation.progress(1); } } function heroSliderStop() { timer.pause() } ScrollTrigger.create({ trigger: '.section-background-overlay', onEnter: heroSliderStart, onLeave: heroSliderStop, }); Notice: the function heroSliderStop() doesn't work now. I need to figure out how to stop the running animation.
  6. Hello, unfortunatelly, we have a problem with playing videos that dynamically change their height althought they have a height value from the begining so that this GSAP animation change its start constantly. Is there a trick to avoid this behaviour?
  7. Thank you very much. Hopefully the last question: is it possible to influnce the velocity/speed of scrub on the mobile devices? At the moment, I use scrub: 2 but the scroll speed is too fast still so I would like to have it more natural when I vertically scroll. All divs horizontally scroll by -100%.
  8. Thank you. But how can I call it outside of my function where I define the Draggable part? At the moment, I could do it for the ScrollTrigger like this. Unfortunatelly, I cannot assing any ID to the Draggable part I defined. Otherwise I could use the same logic like for the ScrollTrigger. Is there any possibility to call the Draggable variation out of the function? Here is my function with the trigger link. $(function() { $('a[data-side-story]').click(function (event) { event.preventDefault(); if (this.hash !== "") { var hashSideStory = this.hash; $(hashSideStory).addClass('active'); $(hashSideStory).parents('.side-story-container').addClass('open-side-story'); var clickedId = $(this).attr('data-id'); var parentId = $(this).attr('data-parent-id'); //console.log(parentId); let cleanSideStoryId = hashSideStory.replace('#', ''); openSideStory(cleanSideStoryId); } }); $('.side-story-trigger-close').click(function (event) { event.preventDefault(); let triggerId = $(this).closest('.side-story-box').attr('id') //console.log("id zum entfernen: " + triggerId); ScrollTrigger.getById(triggerId).kill(true); gsap.set('#'+triggerId, {clearProps: true}); //Draggable.getById(triggerId).kill(true); $('.side-story-box').removeClass('active'); $('.side-story-box').parents('.side-story-container').removeClass('open-side-story'); }); }); function openSideStory(cleanSideStoryId) { let mainContainer = "#"+cleanSideStoryId let containerInside = cleanSideStoryId + "-wrapper" let containerInsideId = document.getElementById(containerInside) let containerInsideWidth = document.getElementById(containerInside).offsetWidth let triggerButton = document.querySelector('.side-story-box.active .side-story-trigger-close') //console.log(triggerButton); let elementSelector = mainContainer + "-wrapper > div" let contentDivs = gsap.utils.toArray(elementSelector) let offsetValue = 0 let scrubValue = 2 if(window.innerWidth >= 800){ offsetValue = 1 scrubValue = 2 } else if (window.innerWidth >= 1280) { offsetValue = 2 } let contentDivsWidth = 0 contentDivs.forEach(e => { contentDivsWidth += e.offsetWidth } ); //console.log(containerInsideWidth); //console.log(contentDivsWidth); //console.log(containerInsideWidth < contentDivsWidth); if (containerInsideWidth > contentDivsWidth) { // do nothing } else { let scrollTween = gsap.to(contentDivs, { xPercent: -100 * (contentDivs.length - offsetValue), ease: "none" }); let horizontalScroll = ScrollTrigger.create({ animation: scrollTween, trigger: mainContainer, id: cleanSideStoryId, start: "top 20", end: () => { return `${100 * contentDivs.length}` }, // "+=3000" () => "+=" + contentDivs.offsetWidth scrub: scrubValue, pin: true, onLeave: function() { triggerButton.addEventListener("click", (e) => { triggerButton.click(); }); }, }); // total scroll amount divided by the total distance that the sections move gives us the ratio we can apply to the pointer movement so that it fits. var dragRatio = containerInsideWidth / (window.innerWidth * (contentDivs.length - 1)); var drag = Draggable.create(".side-story-proxy", { trigger: mainContainer, type: "x", onPress() { this.startScroll = horizontalScroll.scroll(); }, onDrag() { horizontalScroll.scroll(this.startScroll - (this.x - this.startX) * dragRatio); // if you don't want it to lag at all while dragging (due to the 1-second scrub), uncomment the next line: //horizontalScroll.getTween().progress(1); } })[0]; } };
  9. At the end, it works. Thank you. My last question. How can I stop/kill the ScrollTrigger which I have in a function - the ScrollTrigger is as let with name horizontalScroll. I mean I would like to kill it out of the function with a click event.
  10. Thank you very much. Unfortunately, in my case, if I grab it with my mouse and drag it to move it I jump to the top of the page. Is it a common mistake of newbies like me? :)
  11. thank you very much. Is it possible to check the width of the all scrolled divs? In my case, the pinned container has the same width like the main window (css width: 100%). So there is no difference that's why I cannot work with offsetWidthfor the pinned container. Instead of this, I need to get the width of the scrolled divs. My question is: how can I calculate it? In my ScrollTrigger, I use the calculate function to define the end of the animation end: () => { return `+=300 + ${100 * contentDivs.length}`},. If I understand it right something similar I could use to get the width of all scrolling div, right? Thank you for your patience. let mainContainer = contentId var elementSelector = contentId + "-wrapper > div" var contentDivs = gsap.utils.toArray(elementSelector) let offsetValue = 0 let scrubValue = 2 if(window.innerWidth >= 800){ offsetValue = 1 scrubValue = 0.4 } else if (window.innerWidth >= 1280) { offsetValue = 2 } let scrollTween = gsap.to(contentDivs, { xPercent: -100 * (contentDivs.length - offsetValue), ease: "none" }); let horizontalScroll = ScrollTrigger.create({ animation: scrollTween, trigger: mainContainer, end: () => { return `+=300 + ${100 * contentDivs.length}` }, // "+=3000" () => "+=" + contentDivs.offsetWidth scrub: scrubValue, pin: true, onComplete: function() { document.querySelector('.side-story-container').classList.remove('open-side-story'); document.querySelector('.side-story-box').classList.remove('active'); //ScrollTrigger.kill(); gsap.set(parentContainerId, {position: "static"}); }, }); // total scroll amount divided by the total distance that the sections move gives us the ratio we can apply to the pointer movement so that it fits. var dragRatio = mainContainer.offsetWidth / (window.innerWidth * (contentDivs.length - 1)); var drag = Draggable.create(".proxy", { trigger: mainContainer, type: "x", onPress() { this.startScroll = horizontalScroll.scroll(); }, onDrag() { horizontalScroll.scroll(this.startScroll - (this.x - this.startX) * dragRatio); // if you don't want it to lag at all while dragging (due to the 1-second scrub), uncomment the next line: //horizontalScroll.getTween().progress(1); } })[0];
  12. Antoher question. Is it possible to activate the draggen gestures for mobile diveces to able this scrolling possibility too?
  13. Ok. Thank you. Another question. Can I check if it's necessary to scroll the content divs as long as all of them are in the viewport?
  14. Here is the current CodePen https://codepen.io/jankout/pen/BaZNNQw
×