JQuery implementation anchor down smoothing scrolling effect example


Implementation principle:

Implement page using jQuery animate () method Smooth rolling effect

$ (‘HTML, Body’). Animate ({scrolltop: $ (hash) .offset (). TOP}, 800, function () { Window.Location.hash = Hash;});
Simple instance code:

$ (Document) .ready (function () {// add smooth scrolling to all links $ (“a”). On (‘click ” , Function (Event) {// make Sure this.hash Has a value before overriding default behavior if (this.hash! == “”) {// prevent default anchor click behavior event.preventdefault (); // store hash var Hash = this.hash; // using jquery’s animate () Method to add smooth Page Scroll // The Optional Number (800) Specifies The Number of Millis SPECISEconds It Takes To Scroll To The Specified Area $ (‘HTML, Body’). Animate ({scrolltop: $ (hash) .offset (). TOP}, 800, function () {// add hash (#) to URL When Done Scrolling (Default Click Behavior) WINDOW.LOCATION.HASH = HASH;});} // end if});});
body, html, .main {height: 100%;} section {MIN-HEIGHT: 100%;}
  Click here to smooth scroll to the second part              
The above jQuery achieves anchor point smooth scrolling effect example is Xiaobian sharing to everyone. All content, I hope to give you a reference, I also hope that you will support Tumi Clouds.
© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment