Is it possible to trigger something with .resize(); but only when resized to a particular width or height? Or only when size is increased?
Is it possible to trigger something with .resize(); but only when resized to a
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you add a handler to
resize, you will be able to check the element’s size from inside the handler with$(this).height()and$(this).width(). This way you can return without doing anything if the numbers do not satisfy certain characteristics.Detecting dimension increase should be possible by remembering the “last” values and comparing them with the current ones from within the handler, for example:
$(“#id”).resize(function() {
var height = $(this).height();
var width = $(this).width();
});
However, beware: There is no guarantee as to how many times your resize handler will be called during the process of the element being resized (i.e. you may get triggerred continuously or just once at the end), as this depends on the browser.