Skip to content

Commit 234934b

Browse files
committed
Update smoothie
1 parent f7e339f commit 234934b

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

dist/smoothie.js

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,22 @@
2020
exports.default = function () {
2121
// Get the elements marked for smooth scrolling
2222
var elements = document.querySelectorAll('[data-smoothie]');
23-
// Save the href value
24-
var link = void 0;
2523
// For each element get href value
2624
Array.from(elements).forEach(function (element) {
2725
// Save the href value from each element
28-
link = element.getAttribute('href');
29-
// Wrap as a closure
30-
(function (link) {
31-
element.addEventListener('click', function (event) {
32-
// Prevent default behavior
33-
event.preventDefault();
34-
// Load proper hash in the url
35-
history.pushState(null, null, link);
36-
// Scroll into view the element
37-
document.querySelector(link).scrollIntoView({
38-
// Set the animation method
39-
behavior: 'smooth'
40-
});
26+
var link = element.getAttribute('href');
27+
// Create the click events
28+
element.addEventListener('click', function (event) {
29+
// Prevent default behavior
30+
event.preventDefault();
31+
// Load proper hash in the url
32+
history.pushState(null, null, link);
33+
// Scroll into view the element
34+
document.querySelector(link).scrollIntoView({
35+
// Set the animation method
36+
behavior: 'smooth'
4137
});
42-
})(link);
38+
});
4339
});
4440
};
4541

dist/smoothie.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/js/smoothie.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)