2019-10-24 23:27:09 -03:00
|
|
|
function somethingSelected() {
|
|
|
|
return typeof window.getSelection == 'function' && window.getSelection().toString() != "";
|
|
|
|
}
|
|
|
|
const remover = / |\n|\t/g;
|
|
|
|
$('.dragscroll').each(function(_, el) {
|
2019-10-25 02:40:32 -03:00
|
|
|
let previouslyMouseDown = false;
|
2019-10-24 23:27:09 -03:00
|
|
|
el.addEventListener('mousemove', function(e) {
|
2019-10-25 02:40:32 -03:00
|
|
|
if (e.buttons != 1) {
|
2019-10-24 23:27:09 -03:00
|
|
|
if (previouslyMouseDown) {
|
|
|
|
el.style.removeProperty('user-select');
|
|
|
|
el.style.removeProperty('-webkit-user-select');
|
|
|
|
previouslyMouseDown = false;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (somethingSelected())
|
|
|
|
return;
|
|
|
|
if (!previouslyMouseDown) {
|
|
|
|
for (let el of e.target.childNodes) {
|
|
|
|
if (el.nodeType === Node.TEXT_NODE && el.textContent.replace(remover, '').length)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
el.style['user-select'] = 'none';
|
|
|
|
el.style['-webkit-user-select'] = 'none';
|
|
|
|
previouslyMouseDown = true;
|
|
|
|
}
|
2019-11-02 02:20:23 -03:00
|
|
|
//el.scrollLeft -= e.movementX;
|
2019-10-24 23:27:09 -03:00
|
|
|
el.scrollTop -= e.movementY;
|
|
|
|
}, {passive: true});
|
|
|
|
});
|