【问题标题】:mCustomScrollbar Disabling scroll animationmCustomScrollbar 禁用滚动动画
【发布时间】:2016-12-05 13:03:26
【问题描述】:

由于某种原因,我无法在通过 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

【问题讨论】:

    标签: javascript jquery scrollbar mcustomscrollbar


    【解决方案1】:

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

     live: true
    

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

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

    现在可以了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-26
      • 1970-01-01
      相关资源
      最近更新 更多