Jump to content
GreenSock

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

Draggable scrollTop does not show native scroll bar on mobile.

Recommended Posts

Hi,

 

I'm using scrollTop on a div and would like the native scroll bar to show on mobile. It does on the desktop and Chrome on Android 4.1.2 but doesn't on iOS 7.1.1 on iPhone 4S in either Safari or Chrome.

 

I have set -webkit-overflow-scrolling:touch in the css but it's not helping.

 

Any ideas?

 

Thanks

Link to comment
Share on other sites

Draggable sets the overflowX and overflowY to "hidden" on mobile devices because:

  1. There's a bug in some mobile browsers (like Android) that causes scrollTop to get forced back to 0 after it is altered via JS (a total show-stopper for a tool like Draggable)
  2. From what I understand, most (if not all) mobile browsers have that default behavior anyway (overflow is hidden). 

You could manually set the overflowX/overflowY back to "auto" or something AFTER you create your Draggable if you'd like to override that behavior. Like yourElement.style.overflowY = "auto";

  • Like 2
Link to comment
Share on other sites

  • 1 year later...

Draggable sets the overflowX and overflowY to "hidden" on mobile devices because:

  1. There's a bug in some mobile browsers (like Android) that causes scrollTop to get forced back to 0 after it is altered via JS (a total show-stopper for a tool like Draggable)
  2. From what I understand, most (if not all) mobile browsers have that default behavior anyway (overflow is hidden). 

You could manually set the overflowX/overflowY back to "auto" or something AFTER you create your Draggable if you'd like to override that behavior. Like yourElement.style.overflowY = "auto";

Does this actually work for iOS?

Thanks.

Link to comment
Share on other sites

Are you saying it doesn't work for you? Do you have a sample (codepen) that shows the issue? 

Link to comment
Share on other sites

Thanks for the reply Jack!

 

I made a small pen: 

See the Pen XKJewx by wim67 (@wim67) on CodePen

It has a scrollbar on a desktop, not on an iPad.

Link to comment
Share on other sites

Oh, right, iOS just doesn't show scrollbars like that. It's an iOS browser thing. I think Apple considered it a waste of visual space for a touch device. 

  • Like 1
Link to comment
Share on other sites

I believe Windows 10 does the same thing, but different for desktop, where it won't show scrollbars unless you start scrolling on desktop.

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.
×