How to use jQuery jScrollPane and scrollTo plugins in the same script

Patrick Armitage picture Patrick Armitage · Jul 15, 2011 · Viewed 7.4k times · Source

I'm building my first js/jQuery site and I've run into a hiccup. I'm trying to use both jScrollpane (Kelvin Luck) and scrollTo (Ariel Flesler) plugins in one script. If I comment one out, the other works. Are they mutually exclusive? Do I need to unbind functionality out of jScrollpane to remove a 'scrollTo' call conflict or something? (I have no idea how to do that).

I'm using jScrollPane 2beta11 and scrollTo 1.4.2. Here's my stripped-down code using both:

// JavaScript Document
$(document).ready(function() {

    //jScrollPane Init
    $('#scrollingDiv').jScrollPane({
    });

    //scrollTo Refresh
    $('div.scroll-pane').scrollTo( 0 );
    $.scrollTo( 0 );

    //Buttons
    var $scrollDiv = $('#scrollingDiv');
    var next = 1;

    $('#but-rt').click(function(){
    $scrollDiv.stop().scrollTo( 'li:eq(1)', 800 );
    next = next + 1;
    });

});

I'm aware that jScrollPane has it's own scrollTo functionality, but I need scrollTo's jQuery Object selectors in my particular project. I know I've got my HTML/CSS lined up fine because each function works as long as the other is commented out.

(By the way, I plan on using "next" variable to increment scrollTo button once I figure out how... not related to my problem tho.)

Any help is much appreciated. Let me know if there's anything else I need to supply. Thanks!

-Patrick

Answer

Harun picture Harun · Jul 15, 2011

See how to use ScrollTo functionality of JscrollPane from the following url,

http://jscrollpane.kelvinluck.com/scroll_to.html

Hope this will help you...