GDBrowser/misc/dragscroll.js
GDColon ea5c732c75 Assets overhaul + demon list + several misc updates
I held back on pushing this since I wanted to wait for Rob to unblock level downloading, but it's probably gonna be a while since it's (likely) related to an unlisted level exploit

Anyways I totally overhauled how the assets work, and you can also browse through all the files by going to gdbrowser.com/assets, because why not

I also made many other changes and fixes during this timespan including the addition of the demon list, optimized custom lists along with a ?page param, and other random stuff that needed touching up

- Removed Herobrine
2021-01-04 10:21:58 -05: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});
});