diff --git a/src/App.vue b/src/App.vue index c481b8c..99f3f49 100644 --- a/src/App.vue +++ b/src/App.vue @@ -8,6 +8,9 @@ + + +

Parallax fixed position

diff --git a/src/components/Parallax.vue b/src/components/Parallax.vue index 2a78154..83fb2dd 100644 --- a/src/components/Parallax.vue +++ b/src/components/Parallax.vue @@ -81,7 +81,8 @@ const parentHeight = this.$refs.block.offsetHeight const parallaxHeight = this.$refs.parallax.offsetHeight const availableOffset = parallaxHeight - parentHeight - let animationValue = (window.pageYOffset * this.speedFactor) + const scrollOffset = (this.$refs.block.offsetHeight - this.$refs.block.getBoundingClientRect().top) + let animationValue = (scrollOffset * this.speedFactor) if (animationValue <= availableOffset && animationValue >= 0) { this.el.style.transform = `translate3d(0, ${animationValue * this.directionValue}px ,0)` diff --git a/static/img/pexels-photo-3977529.jpg b/static/img/pexels-photo-3977529.jpg new file mode 100644 index 0000000..6e47929 Binary files /dev/null and b/static/img/pexels-photo-3977529.jpg differ