user3056349
user3056349

Reputation: 23

jquery mobile silentScroll animate

I am using the jquery mobile silentScroll to go from one div element to another. The silentScroll is working. But it is a 'jump' from the first element to the next. I want a transition or animation down scroll. I am using the following code.

 $( document ).ready(function() {

  $( "#scrolldown" ).bind( "click", function( event ) {
    // find this element's offset position
    target = $("#helloworld").get(0).offsetTop;
    // scroll the page to that position
    return $.mobile.silentScroll(target);
  });

});

I have searched but I cannot find a solution to animate down to the target element. Thanks in advance.

Upvotes: 1

Views: 2055

Answers (1)

Omar
Omar

Reputation: 31732

The main purpose of using .silentScroll is to scroll without triggering scroll event. If you want to animate scrolling, use the below, but this will trigger scroll event.

$("html, body").animate({ "scrollTop" : target }, 500); /* 500 is speed in ms */

Another note, use page events in jQuery Mobile rather than using .ready().

Upvotes: 3

Related Questions