Skip to content

Instantly share code, notes, and snippets.

@originalpete
Last active October 11, 2016 17:36
Show Gist options
  • Save originalpete/0ee08cc7ba36bbfc49f8f89c36aaf566 to your computer and use it in GitHub Desktop.
Save originalpete/0ee08cc7ba36bbfc49f8f89c36aaf566 to your computer and use it in GitHub Desktop.
Click handler for smoothly scrolling to an element in Unbounced.com
// 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