A
A
Andrey_872018-02-25 20:14:16
JavaScript
Andrey_87, 2018-02-25 20:14:16

Problem with resize in carousel. How to decide?

Hello, connoisseurs)) The problem is in the owl-carusel carousel (I'm not sure if there is a value where), with resize I measure the height of one element and set the same height to the other. The code

$(document).ready(function() {
$(window).resize(function(){
    var height_ggg = Math.round($('.special_carusel').height()+20);
  $('.special_carusel2').css("height", height_ggg + "px");
});
$(window).resize();
});

Everything works, only when the resolution is changed resize "lags behind by one pixel", that is, the size of the block has changed after 1200 px , that is, by 1199 th , and resizing only works at 1198px.
I already broke my head, what could be the problem? Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mdss, 2018-02-25
@mdss

a bike

$('.special_carusel2').css("height", height_ggg + 1 + "px");

A
Andrey_87, 2018-02-26
@Andrey_87

As far as I understand, resize fires earlier than the script that changes the height in the owl carousel, and therefore resize has the old height on this one pixel. And how then to make it work later? I tried to put the script as the latest, but it doesn't help...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question