This is a migrated thread and some comments may be shown as answers.

Disable scrolling temporarily

0 Answers 1006 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ewgenij
Top achievements
Rank 1
Veteran
Ewgenij asked on 26 Feb 2021, 02:40 PM

I want to disable scrolling for the time the next page is being loaded. I use the following combination for that

 

01.private readonly preventDefault = function (e) {
02.    e.preventDefault();
03.    e.stopPropagation();
04.  };
05. 
06.  private disableScrolling() {
07.    window.addEventListener('wheel', this.preventDefault, {passive: false});
08.    window.addEventListener('mousewheel', this.preventDefault, {passive: false});
09.    window.addEventListener('scroll', this.preventDefault, {passive: false});
10.    console.log('scrolling disabled');
11.  }

 

However, the scrolling is disabled after I stop rotating my mouse wheel only. Then, If I start rotating it again, the scrolling will be prevented. But if I don't stop rotating for the first time, the grid will scroll further regardless of the new attached event listeners. What am I doing wrong and how such behaviour can be explained?

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Ewgenij
Top achievements
Rank 1
Veteran
Share this question
or