GDBrowser/assets/dragscroll.js
GDColon 1ab98744e4 Finally added level leaderboards!
- Added level leaderboards
- Nonixestent level IDs are now rounded to nearest whole number
- Removed horizontal dragscrolling (sorry 101arrowz :P)
- Upped search length to 20
2019-11-02 01:20:23 -04:00

30 lines
No EOL
964 B
JavaScript

function somethingSelected() {
return typeof window.getSelection == 'function' && window.getSelection().toString() != "";
}
const remover = / |\n|\t/g;
$('.dragscroll').each(function(_, el) {
let previouslyMouseDown = false;
el.addEventListener('mousemove', function(e) {
if (e.buttons != 1) {
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;
}
//el.scrollLeft -= e.movementX;
el.scrollTop -= e.movementY;
}, {passive: true});
});