Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6636c3e

Browse files
solving the bug that occurs when navigating between routes - spa
1 parent 3bd2ed5 commit 6636c3e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

‎src/vue-parallax-js.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ ParallaxJS.prototype = {
2929
return 'transform'
3030
})(),
3131

32+
remove(el, binding) {
33+
for(let item of this.items){
34+
if(item.el === el){
35+
this.items.splice(this.items.indexOf(el), 1)
36+
}
37+
}
38+
},
39+
3240
add (el, binding) {
3341
if (!window) return
3442
const value = binding.value
@@ -61,8 +69,12 @@ ParallaxJS.prototype = {
6169
this.items.forEach(function (item) {
6270
const t = item.el
6371
const n = t.currentStyle || window.getComputedStyle(t)
72+
6473
item.height = item.mod.absY ? window.innerHeight : t.clientHeight || t.scrollHeight
65-
item.iOT = t.offsetTop + t.offsetParent.offsetTop - parseInt(n.marginTop)
74+
if(t.offsetParent !== null)
75+
item.iOT = t.offsetTop + t.offsetParent.offsetTop - parseInt(n.marginTop)
76+
77+
6678
})
6779
},
6880
move () {
@@ -114,6 +126,9 @@ export default {
114126
inserted (el, binding) {
115127
p.add(el, binding)
116128
p.move(p)
129+
},
130+
unbind(el, binding){
131+
p.remove(el, binding)
117132
}
118133
})
119134
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /