Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery animate scroll

I'm not sure how to call the effect, but can someone point me into a library that would help me do the same effect as this website?

http://www.makr.com

Basically, it moves up the row to the top of the page on mouse click. A code snippet, preferably jQuery, can help to, if there is no such specialized effect library for it.

Im not sure if i need to start another topic, but can anyone help me with a small jQuery snippet to achieve the whole effect of the Makr UI?

like image 606
Marvzz Avatar asked Nov 08 '11 08:11

Marvzz


People also ask

What is jQuery scrollTop?

The scrollTop() method sets or returns the vertical scrollbar position for the selected elements. Tip: When the scrollbar is on the top, the position is 0. When used to return the position: This method returns the vertical position of the scrollbar for the FIRST matched element.

What is jQuery animate?

Definition and Usage. The animate() method performs a custom animation of a set of CSS properties. This method changes an element from one state to another with CSS styles. The CSS property value is changed gradually, to create an animated effect. Only numeric values can be animated (like "margin:30px").

How do I enable animation when the content scrolls into view?

In the code below, this is done by adding a "start" class to the element, that triggers the animation. @Wtower for stuff like that I bind the event to multiple events: $(window). on('scroll scrollstart touchmove orientationchange resize') You could ofcourse add the 'load' event to that.


2 Answers

You can animate the scrolltop of the page with jQuery.

$('html, body').animate({     scrollTop: $(".middle").offset().top  }, 2000); 

See this site: http://papermashup.com/jquery-page-scrolling/

like image 129
Mathieu Avatar answered Sep 18 '22 17:09

Mathieu


You can give this simple jQuery plugin (AnimateScroll) a whirl. It is quite easy to use.

1. Scroll to the top of the page:

$('body').animatescroll(); 

2. Scroll to an element with ID section-1:

$('#section-1').animatescroll({easing:'easeInOutBack'}); 

Disclaimer: I am the author of this plugin.

like image 25
Ram Patra Avatar answered Sep 19 '22 17:09

Ram Patra