mCustomScrollbar 禁用滚动动画

mCustomScrollbar Disabling scroll animation

由于某些原因,通过 javascript 初始化时我无法让滚动条出现,但我可以通过 html.

初始化

滚动条应该出现在 #popup-scroll 内部,其中包含 php 内容。这一切都在画廊内部,弹出窗口充当循环中每个项目的灯箱。

       <?php 
   $the_query = new WP_Query(array(
    'post_type' => 'post')); while ( $the_query->have_posts() ) : $the_query->the_post();?>
    <?php 
      echo'<figure><a class="popup-with-zoom-anim" href="#'.$post->post_name.'">'.the_post_thumbnail().'<div class="title"><h2>'.$post->post_title.'</h2></div></a></figure>';

    echo'<div id="'.$post->post_name.'" class="zoom-anim-dialog mfp-hide">
<div id="popup-scroll">'.$content.'</div></div>'; ?>

   <?php endwhile; wp_reset_postdata(); ?> 

通过 javascript 初始化(不起作用):

<script>
    (function($){
        $(window).on("load",function(){
            $("#popup-scroll").mCustomScrollbar({scrollInertia: 0});
        });
    })(jQuery);
</script>

通过 HTML 初始化(有效):

<div id="popup-scroll" class="mCustomScrollbar" data-mcs-theme="dark">
  <!-- the content -->
</div>

目标是禁用滚动动画scrollInertia: 0,这只能通过javascript初始化来完成。

The developer site, for reference

好的,因为滚动条位于 div 中,只有在打开灯箱/模式 window 后才会出现,所以我必须将以下内容添加到我的脚本中:

 live: true

所以,完整的 javascript 函数是这样的:

 <script>
    (function($){
        $(window).on("load",function(){
            $("#popup-scroll").mCustomScrollbar({
                scrollInertia: 0,
                live: true
            });
        });
})(jQuery);
</script>

现在有效。