2016-07-31 5 views
0

어떤 이유로 든 자바 스크립트를 통해 초기화 할 때 스크롤 막대가 나타나지 않지만 HTML을 통해 초기화 할 수 있습니다.mCustomScrollbar 스크롤 애니메이션 비활성화

#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(); ?> 

(작동하지 않습니다) :

<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

답변

0

좋아, 스크롤 막대는 라이트/모달 창이 열리면, 나는 내 스크립트에 다음을 추가했다 나타납니다 사업부에 있기 때문에 : 그래서

live: true 

, 자바 스크립트 함수는 다음과 같습니다.

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

이제 작동합니다.

관련 문제