asvd / dragscroll

micro library for drag-n-drop scrolling style
http://asvd.github.io/dragscroll/
MIT License
1.09k stars 168 forks source link

Can I use dragscroll only with middle click ? #61

Closed unkobweb closed 2 years ago

unkobweb commented 2 years ago

Hi !

I try to use the dragscroll but only when the user use the middle click of his mouse. I want to prevent the scroll with the left and right click, anny idea of how ?

Thanks

unkobweb commented 2 years ago

Okay, i fix it by myself by adding this line

if (e.button !== 1) return;

In :

(cont = el.container || el)[addEventListener](
    mousedown,
    cont.md = function(e) {
        if (e.button !== 1) return;
        if (!el.hasAttribute('nochilddrag') ||
            _document.elementFromPoint(
                e.pageX, e.pageY
            ) == cont
        ) {
            pushed = 1;
            lastClientX = e.clientX;
            lastClientY = e.clientY;

            e.preventDefault();
        }
    }, 0
);