Created
August 21, 2018 21:06
-
-
Save vprasanth/05f34d5a15d2804fbefbab876f1e1519 to your computer and use it in GitHub Desktop.
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
// 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