Jump to content
Search Community

Scrolltrigger Animation is acting weird on iOS

kadircakir test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hey GSAP team,

 

I have finally implemented this awesome animation thanks to Scrolltrigger.

There is something weird we are experiencing on iOS devices though. The video seems to snap back without finishing the video and when scrolled down scale/grow on its own without interacting.

 

I made an screen recording to give a better idea as everything is working fine in codepen and desktop devices.

https://www.dropbox.com/scl/fi/523nany5speehrbfp06jp/RPReplay_Final1698089823.mp4?rlkey=0242obc90ektonmk3mocykzk5&dl=0

 

The animation is set up as;

<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.4/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.4/ScrollTrigger.min.js"></script>

<script>

const video = document.querySelector('.section-pin video source');

if (window.matchMedia("(max-width: 991px)").matches) {
	video.src = video.dataset.tabletSrc;
} else if (window.matchMedia("(max-width: 767px)").matches) {
video.src = video.dataset.mobileSrc;
} else {
video.src = video.dataset.src;
}
video.closest('video').load();
video.closest('video').play();


ScrollTrigger.defaults({
  markers: false
});

ScrollTrigger.create({
  trigger: ".scale-video-wrapper",
  start: "top top",
  end: '+=1000',
  pin: '.section-pin'
});

const tl = gsap.timeline({
  scrollTrigger: {
    trigger: ".scale-video-wrapper",
    start: "top top+=100px",
    end: "+=1000px",
    toggleActions: "play reverse play reverse"
    // scrub: true
  }
});
tl.to(".video", {
  duration: 0.2,
  scale: 1,
  // ease: "none",
  ease: "power4.in"
});

function onVideoHasEnded() {
  tl.reverse();
}
</script>

<script>
document.querySelector('.section-pin video').addEventListener("ended", function() {
    onVideoHasEnded()
});
</script>

 

Here is a prototype link for own testing if needed; https://glasnu-nl-20.webflow.io/glasnu-nl/video

 

Any idea what could be causing this?

 

Thanks in advance!

Edited by kadircakir
Added prototype for testing
Link to comment
Share on other sites

Rodrigo you are AMAZING!

 

It felt like I was about to lose my mind with this.

When pinned true animation was working all fine, but when pinned to a specific section on the page it went all looney tunes.

 

This worked like a charm!

ScrollTrigger.config({ ignoreMobileResize: true })

 

Thanks a lot man, now I can finally get some sleep, haha.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...