查找光滑滑块容器高度的问题

在尝试为单击标题框后显示的平滑滑块获取容器的高度时出现问题。

我试图捕获高度,并使用该高度将其他标题框向下移动正确的数量,但它捕获的是三个幻灯片的高度,而不是它们凝聚成一个平滑的滑块,所以它打乱了我的布局。因为有3张幻灯片,我的容器最终高出了大约3倍,而且它把其他标题框推得太低了。

这快把我逼疯了。有什么帮助吗?

https://codepen.io/Finches/pen/vpZqYR

// Show/hide content from clicking box title
$('.track-box-title').click(function() {
  //Get height of content
  var height = $(this).parent('.track-box').parent('.track-box-container').find('.track-content').height() + 250;

  console.log(height);

  //Convert height to string
  var heightStr = height.toString();

  //Toggle height and content box display
  if ($(this).parent('.track-box').parent('.track-box-container').height() == 200) {
      $(this).parent('.track-box').parent('.track-box-container').animate({height: heightStr});
      $(this).parent('.track-box').parent('.track-box-container').find('.track-content').show();
      // initialize slick slider
      $(this).siblings('.track-content').find('.project-image-slider').slick({});
    }
    else if ($(this).parent('.track-box').parent('.track-box-container').height() == height) {
      $(this).parent('.track-box').parent('.track-box-container').find('.track-content').hide();
      $(this).parent('.track-box').parent('.track-box-container').animate({height: "200px"});
      $(this).siblings('.track-content').find('.project-image-slider').hide();
    }

});

$('.close-btn').click(function() {
  $(this).parent('.content').parent('.track-content').hide();
  $(this).parent('.content').parent('.track-content').parent('.track-box').parent('.track-box-container').animate({height: "200px"});
});

转载请注明出处:http://www.hnph-smd.com/article/20230526/2474962.html