Last active
October 11, 2016 17:36
-
-
Save originalpete/0ee08cc7ba36bbfc49f8f89c36aaf566 to your computer and use it in GitHub Desktop.
Click handler for smoothly scrolling to an element in Unbounced.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load this after the document has loaded. | |
$(function () { | |
// Bind a click handler to the element. | |
// Note this element needs to exist in both | |
// mobile and tablet views, with the same ID. | |
$("#lp-pom-image-114").click(function (){ | |
// Extract the absolute pixel location of the top of the element | |
// that you want to scroll to. | |
// Note this element needs to exist in both | |
// mobile and tablet views, with the same ID. | |
var offset = $("#lp-pom-block-9").offset().top; | |
// Scroll the body using jQuery animate, over 1000ms. | |
$('body').animate({ | |
scrollTop: offset | |
}, 1000); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment