2016-03-24 7 views
0

Ich weiß, dass es so viele Fragen gibt, aber ich konnte keine Lösung für mein Problem finden.mCustomScrollbar "scrollTo" funktioniert nicht in einer einzigen Anwendung

In meiner Einzelseitenanwendung (mit Metro-Stil), wenn ich von einem Widget nach Hause gehe, möchte ich die Scroll-Position zurück, wo es war, bevor Sie das Widget eingeben.

<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>

Dies ist der Code, der das Plugin erstellt, wenn ich es in die div gelten #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 })

Dann benutze ich die Position im Callback so gefunden

$("#overflow").mCustomScrollbar("scrollTo",scrollLeft);

Aber nichts passiert. Wenn ich versuche, einen Wert wie 3000, manchmal # overflow scrollt, aber die Bildlaufleiste bleibt in der ursprünglichen Position.

Vielen Dank im Voraus, Matteo

Antwort

0

I did it! Ich verwendete die scrollTo Methode im onUpdate Rückruf

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

Verwandte Themen