garand / sticky

jQuery Plugin for Sticky Objects
Other
3.3k stars 1.06k forks source link

Scrolling on a mobile devices #197

Open mkaschke opened 8 years ago

mkaschke commented 8 years ago

Problem: The sticky menu only shows up when the user stops scrolling.

On mobile devices the user is scrolling for a long distance so the sticky menu shows up really late and it looks like an error.

thx

rabbithops commented 8 years ago

Noticed on Google Chrome (Apple IOS).

SharpEdgeMarshall commented 8 years ago

+1

hknaksu commented 8 years ago

+1

jkcjkc82 commented 8 years ago

This is a bug in ios related to position:fixed. However sticky.js sets position:fixed dynamically. If you use this way, you never avoid the issue. In order to avoid this, you should use the way to be changed by scrollTop

for example in css:

header {position:fixed;width:100%;top:44px;}
.is-sticky header {top:0px;}

for example in js:

        $(window).on('scroll', () => {
            let scrollTop = $(window).scrollTop();

            if(scrollTop > 44) {
                $(document.body).addClass('is-sticky');
            } else {
                $(document.body).removeClass('is-sticky');
            }
        })
xrochoa commented 8 years ago

Adding transform: translate3d(0, 0, 0); to the sticky element fixed the issue for me.

It would be great to add s.stickyElement.css('transform', 'translate3d(0px, 0px, 0px)'); after s.stickyWrapper.css('height', s.stickyElement.outerHeight()) in the plugin.

weinbee commented 8 years ago

god bless you, @xrochoa

samjonesigd commented 7 years ago

@xrochoa bug still present for me on iPad ios10