tkahn / Smooth-Div-Scroll

A jQuery plugin for smooth scrolling. No longer maintained.
471 stars 184 forks source link

Disable hotspotscrolling on touch devices #156

Open makani-ph opened 10 years ago

makani-ph commented 10 years ago

Hi, is it possible to disable the hotspotscrolling when the device handheld is recognized (by CSS media query) I've tried something like this: @media handheld { div.scrollingHotSpotLeft { width: 0px; } div.scrollingHotSpotRight { width: 0px; } div.scrollingHotSpotLeftVisible { width: 0px; } div.scrollingHotSpotRightVisible { width: 0px; } } but on my Android 2.3.6 the elements are still visible and clickable causing a continuous scroll. It would be easier if i could set the hotSpotScrolling: to false but i assume there's no css class declared for it yet.

Thanks upfront.

ptolp commented 10 years ago

I've used the following snippet for detecting touch device and then disabling hotspots.

// remove smoothDivScroll hotspots on touchscreen
var hasTouch;
window.addEventListener('touchstart', function setHasTouch () {
    hasTouch = true;
    $("#makeMeScrollable").smoothDivScroll({
            hotSpotScrolling: false,
        });    
    window.removeEventListener('touchstart', setHasTouch);
}, false);

The method works best when hotspots are only shown when hovering the scrollable area, since it requires that user triggers a touch event first.