Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$(window).resize(): Before

Is it possible of getting the width/height of browser each time BEFORE the resize() is triggered?

$(window).resize(function() {

});

This is due to I'm calculating the difference before/after browser has resize().

like image 435
Roy Lee Avatar asked Dec 26 '22 20:12

Roy Lee


1 Answers

You would have to store the previous value, a little like this

var prevHeight = 0;
var prevWidth = 0;

$(document).ready(function() {
    prevHeight = $(window).height();
    prevWidth = $(window).width();
});

$(window).resize(function() {
    var currentHeight = $(window).height();
    var currentWidth = $(window).width();

    //do difference stuff

    prevHeight = currentHeight;
    prevWidth = currentWidth;
});
like image 59
Chris Avatar answered Dec 29 '22 10:12

Chris