Skip to content

Instantly share code, notes, and snippets.

@vprasanth
Created August 21, 2018 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vprasanth/05f34d5a15d2804fbefbab876f1e1519 to your computer and use it in GitHub Desktop.
Save vprasanth/05f34d5a15d2804fbefbab876f1e1519 to your computer and use it in GitHub Desktop.
// iffe
(function() {
'use strict';
const nav = [
{
element: '#home-button',
target: '#scroll-to-home'
},
{
element: '#couple-button',
target: '#scroll-to-couple'
},
{
element: '#story-button',
target: '#scroll-to-story'
},
{
element: '#events-button',
target: '#scroll-to-events'
},
{
element: '#people-button',
target: '#scroll-to-people'
},
{
element: '#faq-button',
target: '#scroll-to-faq'
},
{
element: '#rsvp-button',
target: '#scroll-to-rsvp'
}
];
for(let i = 0; i < nav.length; i++) {
let ele = document.querySelector(nav[i].element);
ele.addEventListener('click', function() {
document.querySelector('#scroll-to-rsvp').scrollIntoView({ behavior: 'smooth' });
});
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment