Scroll to Section with Animation

Nowadays I noticed that most of newer website have those feature that when you clicked a link, and then it scroll to the particular section of the page. Here’s my own simple version how to do scroll to section.

HTML

<a href="#el1" class="click">Click this to scroll to element 1!</a><br />
<a href="#el2" class="click">Click this to scroll to element 2!</a><br />
<a href="#el3" class="click">Click this to scroll to element 3!</a><br />

<section id="el1">element 1</section>
<section id="el2">element 2</section>
<section id="el3">element 3</section>

JS

var scrollTo = {

 init : function () {
   this.button();
 },

 button : function () {
   $('.click').click(function(e){
     // prevent default action
     e.preventDefault();
     var target = $(this).attr('href');
 
     // get id of target div (placed in href attribute of anchor element)
     // and pass it to the scrollToElement function
     // also, use 2000 as an argument for the scroll speed (2 seconds, 2000 milliseconds)
     scrollTo.element( target, 2000 );
   });
 },

 element : function (el, ms) {
   var speed = (ms) ? ms : 600;
   $('html,body').animate({
     scrollTop: $(el).offset().top
   }, speed);
 }

}

scrollTo.init();

CSS

div {
  margin-top:1000px;
}
div:last-child {
  padding-bottom:1000px;
}

Old New Tab Google Chrome

1. Type chrome://flags into your browser's address bar.
2. Search for the option labeled "Enable Instant Extended API."
3. Change its setting from "Default" to "Disabled."
4. Restart your browser.

DeskConnect Files Location

For DeskConnect users in MB. You can find your files here.

1. Command + Space
2. Search for Terminal
3. Open Terminal
4. type this open ~/Library/Containers/com.deskconnect.mac/Data/Library/Application\ Support/DeskConnect