Jump to content
Search Community

scrollTop not working on ios

Johny13 test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi guys,

i have a problem when using scrollTop on ios phones that cant recognize. Is there a way to fix it? This is my code: 

        TweenMax.set('.trail-wrapper', { alpha: 0 })
        TweenMax.set('.cloud', { alpha: 0 })
        var tl = new TimelineMax({ paused: true });

        tl.to('.trail-wrapper', 0.5, { alpha: 1 })
            .to('.cloud', 0.5, { alpha: 1 })
            .to('.rocket-wrapper', 1.5, { y: -400, ease: Expo.easeIn })
            .to('.cloud', 2.5, { attr: { cy: 185 }, ease: Expo.easeIn }, "-=3")
            .set('.cloud', { clearProps: "all" })
            .set('.rocket-wrapper', { y: 0 })
            .to('body', 1, { scrollTop: 0, autoKill:false })
            .to('.rocket-wrapper', 4, { y: 0, ease: Elastic.easeOut.config(0.5, 0.4) })
            .to('.trail-wrapper', 2.5, { scaleX: 0.5, scaleY: 0, alpha: 0, ease: Expo.easeOut }, "-=2.0")

        $('.toTop').on('click', function () {


Link to comment
Share on other sites

Hi @Johny13


Are you sure the element you're targeting is actually scrollable? You can get the current scroll position of an element like this:

var body = document.querySelector('body');


I tried adding a div parent with 'overflow:scroll' and set it as the scroll container in the tween, and it worked just fine as far as I could tell.


Edit: In Codepen it's the parent element of the body that gets the scrollbars.

  • Like 3
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...