Skip to content

Commit 7bd3953

Browse files
onedr0prigor789
authored andcommitted
Allow setting offset in directive (#7)
* Allow setting offset in directive The change to the implementation is: ```html <a href="#" v-scroll-to="{ 'scrollTo': '#section-' + index, 'offset': -75 }" class="nav-link">{{ link.name }}</a> ``` Let me know what you think! Closes #6 * Update index.js Change scrollTo to el and make object optional, if you have any other changes feel free to update :) thanks! * Update index.js This makes more sense..
1 parent ca329d6 commit 7bd3953

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,16 @@ exports.install = function (Vue) {
2828
function handleClick(e) {
2929
e.preventDefault()
3030

31-
exports.scrollTo(this.value, 500, {
31+
if (typeof this.value === 'object') {
32+
exports.scrollTo(this.value.el, 500, {
33+
easing: exports.easing['ease'],
34+
offset: this.value.offset
35+
})
36+
} else {
37+
exports.scrollTo(this.value, 500, {
3238
easing: exports.easing['ease']
33-
})
39+
})
40+
}
3441
}
3542

3643

0 commit comments

Comments
 (0)