css - How can I disable scrolling when there's a modal using nextjs tailwind? - TagMerge
3How can I disable scrolling when there's a modal using nextjs tailwind?How can I disable scrolling when there's a modal using nextjs tailwind?

How can I disable scrolling when there's a modal using nextjs tailwind?

Asked 1 years ago
1
3 answers

I didn't test the result but try to write the if statement inside useEffect() hook. I think initially the document object is unknown to nextJs same goes for the global window object!

For side-effects always try to use useEffect() hook. useEffect() runs after the component is mounted on the DOM.

Source: link

0

Example
body {  overflow: hidden; /* Hide scrollbars */}
Example
body {  overflow-y: hidden; /* Hide vertical scrollbar */  
  overflow-x: hidden; /* Hide horizontal scrollbar */}
Example
/* Hide scrollbar for Chrome, Safari and Opera */
  .example::-webkit-scrollbar {  display: none;}/* Hide scrollbar 
  for IE, Edge and Firefox */.example {  -ms-overflow-style: none;  /* 
  IE and Edge */  scrollbar-width: none;  /* Firefox */}

Source: link

0

If anyone is still looking for a solution, i fixed it with little userscript
// ==UserScript==
// @name         Firefox No Scroll On Drag
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Firefox 57+ disable annoying scroll on drag
// @author       areafix
// @include      http://*/*
// @include      https://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function disableScrolling(){
        var x=window.scrollX;
        var y=window.scrollY;
        window.onscroll=function(){window.scrollTo(x, y);};
    }

    function enableScrolling(){
        window.onscroll=function(){};
    }

    window.ondragstart = function () {
        disableScrolling();
    };

    window.ondragend = function () {
        enableScrolling();
    };

})();

Source: link

Recent Questions on css

    Programming Languages