0

Is there an easy way in GWT/JavaScript to deactivate a scrollbar? It should still be visible but grayed out. It should only rely on GWT, pure JavaScript and/or CSS. The only things I found was how to hide the scrollbar but that's not what I need.

So far I found a feasible solution which sets the scrollbar height to 0 while I want it to be deactivate and set the height back to the normal value once I resume navigation.

Philipp
  • 2,376
  • 5
  • 29
  • 47
  • is css solution ok? – Tomasz Bubała Mar 20 '18 at 10:14
  • Yes, that would be OK as well. I will mention this – Philipp Mar 20 '18 at 10:15
  • `body{position: fixed; overflow-y: scroll; width: 100%;}` - here you go – Tomasz Bubała Mar 20 '18 at 10:17
  • You don't need jQuery, e.g. `document.querySelector('selector').addEventListener('scroll', function(e) { e.preventDefault(); e.stopPropagation(); return false; })` – Asons Mar 20 '18 at 10:21
  • If you want to have an answer to relate to, and upvote, I can post one at the dupe link using the above javascript version, though I find that not necessary as it is easy to search for a jQuery-to-javascript event handler replacement. – Asons Mar 20 '18 at 10:25
  • @LGSon As I understand your solution prevents the events after the scrollbar has been moved but it can be moved? – Philipp Mar 20 '18 at 12:58
  • Since you said you couldn't use jQuery, what I wanted to show was how one use plain javascript instead, to attach a handler. The solution itself isn't mine, I just linked to it, but in short, when the event fires, the called methods prevent an element to e.g. scroll. – Asons Mar 20 '18 at 13:12
  • I understand that. But this still allows the scrollbar to be moved - with no effect - but that is in my opinion confusing behaviour and is not be a reasonable solution. – Philipp Mar 20 '18 at 13:17

0 Answers0