2016-03-24 20 views
0

私はそのような質問がたくさんあることを知っていますが、私の問題の解決策を見つけることができませんでした。mCustomScrollbar "scrollTo"は単一のページアプリケーションでは動作しません

私がウィジェットから家に戻ったときの私の単一ページアプリケーション(メトロスタイル)では、ウィジェットに入る前の位置にスクロール位置を戻したいと思います。

この

<div id="overflow" class="mCustomScrollbar _mCS_9" style="width: 1855px;"> 
 
    <div id="mCSB_9" class="mCustomScrollBox mCS-jmsHorizontalScrollbar mCSB_horizontal mCSB_inside" style="max-height: none;" tabindex="0"> 
 
     <div id="mCSB_9_container" class="mCSB_container" style="position: relative; top: 0px; left: 0px; width: 8360px;" dir="ltr"> 
 
     <div class="page" id="dashboard_all" style="width: 8360px;"> 
 
     </div> 
 
     </div> 
 
     <div id="mCSB_9_scrollbar_horizontal" class="mCSB_scrollTools mCSB_9_scrollbar mCS-jmsHorizontalScrollbar mCSB_scrollTools_horizontal" style="display: block;"> 
 
     <a href="#" class="mCSB_buttonLeft" oncontextmenu="return false;" style="display: block;"></a> 
 
     <div class="mCSB_draggerContainer"> 
 
      <div id="mCSB_9_dragger_horizontal" class="mCSB_dragger" style="position: absolute; min-width: 30px; display: block; width: 403px; max-width: 1805px; left: 0px;" oncontextmenu="return false;"> 
 
       <div class="mCSB_dragger_bar"></div> 
 
      </div> 
 
      <div class="mCSB_draggerRail"></div> 
 
     </div> 
 
     <a href="#" class="mCSB_buttonRight" oncontextmenu="return false;" style="display: block;"></a> 
 
     </div> 
 
    </div> 
 
</div>
は私が位置を使用 #overflow

$(document).ready(function() { 
 
\t \t \t $("#overflow").mCustomScrollbar({ 
 
\t \t   axis:"x", 
 
\t \t   theme:"jmsHorizontalScrollbar", 
 
\t \t   scrollButtons: { 
 
\t \t   \t enable: true 
 
\t \t   }, 
 
\t \t   scrollInertia: 950, 
 
\t \t \t \t callbacks:{ 
 
\t \t \t \t \t onScroll:function(){ 
 
\t \t \t \t \t \t //this functions sets the value in another js file. -(this.mcs.left) to get a positive value 
 
\t \t \t \t \t \t getNavigator().setScrollLeft(-(this.mcs.left)); 
 
\t \t \t \t \t }, 
 
\t \t \t \t \t alwaysTriggerOffsets:false 
 
\t \t \t \t } 
 
\t \t  }); 
 
\t \t })

その後のdivにそれを適用するときにプラグインが作成するコードですそのようなコールバックに見つかりました

$("#overflow").mCustomScrollbar("scrollTo",scrollLeft);
しかし、何も起こりません。 3000のような値を入力しようとすると、ときどき #overflowがスクロールしますが、スクロールバーは初期位置にとどまります。

は マッテオ

答えて

0

が、私はそれをやった、事前にありがとうございます!私は、コールバックにonUpdate

onUpdate:function(){ 
 
    $("#overflow").mCustomScrollbar('scrollTo',position, { 
 
    // scroll as soon as clicked 
 
    timeout:0, 
 
    // scroll duration 
 
    scrollInertia:0, 
 
    }); 
 
}

にscrollToメソッドを使用しました