Skip to content

Commit 87fdf0d

Browse files
committed
add option to correct for vertical overscroll in certain browsers with overScrollFix option
1 parent 4d92c1f commit 87fdf0d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

parallax.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
iosFix: true,
159159
androidFix: true,
160160
position: 'center',
161+
overScrollFix: false,
161162

162163
refresh: function() {
163164
this.boxWidth = this.$element.outerWidth();
@@ -211,6 +212,7 @@
211212
render: function() {
212213
var scrollTop = Parallax.scrollTop;
213214
var scrollLeft = Parallax.scrollLeft;
215+
var overScroll = this.overScrollFix ? Parallax.overScroll : 0;
214216
var scrollBottom = scrollTop + Parallax.winHeight;
215217

216218
if (this.boxOffsetBottom > scrollTop && this.boxOffsetTop < scrollBottom) {
@@ -225,7 +227,7 @@
225227
this.$mirror.css({
226228
transform: 'translate3d(0px, 0px, 0px)',
227229
visibility: this.visibility,
228-
top: this.mirrorTop,
230+
top: this.mirrorTop - overScroll,
229231
left: this.mirrorLeft,
230232
height: this.boxHeight,
231233
width: this.boxWidth
@@ -267,6 +269,7 @@
267269
var scrollLeftMax = Parallax.docWidth - Parallax.winWidth;
268270
Parallax.scrollTop = Math.max(0, Math.min(scrollTopMax, $win.scrollTop()));
269271
Parallax.scrollLeft = Math.max(0, Math.min(scrollLeftMax, $win.scrollLeft()));
272+
Parallax.overScroll = Math.max($win.scrollTop() - scrollTopMax, Math.min($win.scrollTop(), 0));
270273
Parallax.requestRender();
271274
})
272275
.on('resize.px.parallax load.px.parallax', function() {

parallax.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)