Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/376.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 动态重新计算引导粘贴';jQuery单击事件上的s offset()_Javascript_Jquery_Twitter Bootstrap_Affix - Fatal编程技术网

Javascript 动态重新计算引导粘贴';jQuery单击事件上的s offset()

Javascript 动态重新计算引导粘贴';jQuery单击事件上的s offset(),javascript,jquery,twitter-bootstrap,affix,Javascript,Jquery,Twitter Bootstrap,Affix,在我的应用程序中,我有两个jQuery函数: 第一个管理一个简单的滑动切换: $( ".js-support-toggle" ).click(function(e) { e.preventDefault(); $('.filter-weight').toggleClass('open'); $('.filter-weight .dropdown-body').slideToggle(); }); 和相应的标记: <section class="dropdown f

在我的应用程序中,我有两个jQuery函数:

第一个管理一个简单的滑动切换:

$( ".js-support-toggle" ).click(function(e) {
    e.preventDefault();
    $('.filter-weight').toggleClass('open');
    $('.filter-weight .dropdown-body').slideToggle();
});
和相应的标记:

<section class="dropdown filter-weight">
    <a class="dropdown-title js-filter-toggle">Filter</a>
    <div class="dropdown-body">
        ...
    </div><!-- /dropdown-body-->
</section>
该偏移量是通过收集粘贴菜单上方每个元素的outerHeight()值来确定的,包括我的滑动切换
。筛选权重
元素

.filter weight
元素折叠时,这一切都非常有效。但是,如果用户将其切换打开,然后向下滚动页面,则切换元素的添加高度会影响偏移量计算

如何重写我的offset()以动态调整到我的
过滤器权重
元素的可变高度

/* Affixes sidebar nav to top of screen */
$('#scrollspy').affix({
  offset: {
    top: function () {
      return (this.top = $('.header-wrapper').outerHeight(true) + $('.filter-weight').outerHeight(true) + $('.secondary-navigation').outerHeight(true) + $('.filter-weight').outerHeight(true) + 100)
    },
    bottom: function () {
      return (this.bottom = $('.footer').outerHeight(true))
    }
  }
})