T
T
tripcollor2018-01-24 15:25:30
JavaScript
tripcollor, 2018-01-24 15:25:30

Why does the native js function resize not work on Mozilla when you click on the "minimize to window" button?

Wrote the following script to adjust the auto-height

Show script
function autoHeight(object){
      var fluid = object.fluid;
      var subtract = object.subtract ? object.subtract : null;

      function run(){
        var fluidHeight = document.querySelector(fluid).offsetHeight;
        var mainHeightScroll = document.documentElement.scrollHeight;
        var mainHeightNoScroll = document.documentElement.offsetHeight;

        if(subtract){
          var subtractHeight = document.querySelector(subtract).offsetHeight;
        } else{
          var subtractHeight = 0;
        }
        

        if((fluidHeight + subtractHeight) <= mainHeightNoScroll){
          document.querySelector('.setpassword').style.height = (mainHeightScroll - subtractHeight)+"px";
        } 
        if((fluidHeight + subtractHeight) > mainHeightNoScroll){
          document.querySelector('.setpassword').style.height = "auto";
        }
      }

      run();
      window.addEventListener('load', run);
      window.addEventListener('resize', run);
    }

    autoHeight({
      fluid: '.setpassword',
      subtract: '.topbars',
    });


But for some reason, on the muzzle, here is the site , when you click on the "minimize to window" button, the resize function is not caught and the script does not work, although it's normal on chrome, I tried to write jq instead of vanilla js and everything is fine. How to overcome this and do it in pure js?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tyzberd, 2018-01-24
@tripcollor

here it works in moz https://jsfiddle.net/tyzberd/ffz07pkj/
took here https://developer.mozilla.org/ru/docs/Web/Events/resize

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question