Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1372420

    Hi. I am a new user of Enfold and I am using it to build my site.
    I wanted to ask how I could make a scroll trigger animation (similar to what you see on Apple’s site) using a video.
    Reading the Enfold documentation, I thought about making a colorsection with a video as the background and then using GSAP to play the video (https://youtu.be/J0gUOaSlQjs) when you scroll down the page, and have a text appear shortly after onto the video (such color section center-aligned content), but I’m not sure if this is the right way.
    I currently have this code written, but when I go to test it I have enough problems, especially with the next color section overlapping this one:

    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.3.1/gsap.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.3.1/ScrollTrigger.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <script>
    	jQuery(document).ready(function(){
    		const colorSection = "#litappliances"; // id of the color section
    		const video = jQuery(colorSection).find("video")[0];
    		const overlay = jQuery(colorSection).find(".av-section-color-overlay-wrap")[0];
    		
    		video.pause();
    		video.currentTime = 0.01;
    
    		let src = video.currentSrc || video.src;
    
    		jQuery(document).on("touchstart", function(e){
    			video.play();
    			video.pause();
    		});
    
    		/* ---------------------------------- */
    		/* Scroll Control! */
    
    		gsap.registerPlugin(ScrollTrigger);
    
    		jQuery(video).on("loadedmetadata", function() {
    			let tl = gsap.timeline({
    				defaults: { duration: 1 },
    				scrollTrigger: {
    					trigger: "#litappliances",
    					start: "top top",
    					end: "+=20%",
    					pin: false,
    					scrub: true
    				}
    			});
    			
    			tl.fromTo(video, { currentTime: 0 }, { currentTime: video.duration || 1 });
    			let t2 = gsap.timeline({
    				defaults: { duration: 1 },
    				scrollTrigger: {
    					trigger: "#litappliances",
    					start: "top top",
    					end: "+=20%",
    					pin: true,
    					scrub: true
    				}
    			});
    			t2.fromTo(label, { opacity: 0 }, { opacity:1 });
    		});
    	});
    </script>

    How could I solve this? Thanks in advance for your attention!

    #1372425

    Hey lucapada,
    Thanks for your question, but I don’t have any experience with GSAP, if you are having trouble with playing the clip I found this thread about this with this working example.

    I was not very clear on your goal, I tried creating a page with 3 color sections, each set to 100vh, with the background video in the middle section:
    2022-11-13_004.png
    and in my test without your script the video doesn’t start playing until it is in view.
    So perhaps you don’t need the script to achieve this?

    Best regards,
    Mike

    #1372559

    Hi Mike, thanks for the demo!
    My problem is that the video should be synchronized with the browser’s scroll down event (as you can see on this apple’s page: https://www.apple.com/airpods-3rd-generation/). The color section (and all the content that comes after) should be fixed until the end of the video, then it can be unlocked and the page can scroll. Also, if I scroll down, the video should go forward, if I scroll up, the video goes backward. If I don’t scroll, the video should be paused.

    #1372569

    Hi,
    Thanks for the explanation but unfortunately we don’t have a built-in way to achieve this. It looks like the GSAP script could achieve this and you are probably close to doing so, but it seems that you will require more specific GSAP advice than we can offer here. Perhaps the GSAP forum would help, or StackOverflow would be more knowledgeable in achieving this.

    Best regards,
    Mike

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Scroll trigger animation and color section’ is closed to new replies.