Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix left value not updating when scrolling horizontally with fixed position #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion dist/jquery.sticky-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@
key: '_calcDimensionsWithScroll',
value: function _calcDimensionsWithScroll() {
var dims = this.dimensions;
var lastViewportLeft = dims.viewportLeft;

dims.sidebarLeft = StickySidebar.offsetRelative(this.sidebar).left;

Expand All @@ -334,12 +335,16 @@
if (dims.topSpacing < dims.lastTopSpacing) {
dims.translateY += dims.lastTopSpacing - dims.topSpacing;
this._reStyle = true;
} else if (lastViewportLeft !== dims.viewportLeft) {
this._reStyle = true;
}
} else if ('VIEWPORT-BOTTOM' === this.affixedType) {
// Adjust translate Y in the case decrease bottom spacing value.
if (dims.bottomSpacing < dims.lastBottomSpacing) {
dims.translateY += dims.lastBottomSpacing - dims.bottomSpacing;
this._reStyle = true;
} else if (lastViewportLeft !== dims.viewportLeft) {
this._reStyle = true;
}
}

Expand Down Expand Up @@ -454,7 +459,7 @@
left: dims.sidebarLeft - dims.viewportLeft, width: dims.sidebarWidth };
break;
case 'VIEWPORT-BOTTOM':
style.inner = { position: 'fixed', top: 'auto', left: dims.sidebarLeft,
style.inner = { position: 'fixed', top: 'auto', left: dims.sidebarLeft - dims.viewportLeft,
bottom: dims.bottomSpacing, width: dims.sidebarWidth };
break;
case 'CONTAINER-BOTTOM':
Expand Down Expand Up @@ -486,6 +491,7 @@
if (this._breakpoint) return;

force = this._reStyle || force || false;
this._reStyle = false;

this.options.topSpacing;
this.options.bottomSpacing;
Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.sticky-sidebar.min.js

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion dist/sticky-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@
key: '_calcDimensionsWithScroll',
value: function _calcDimensionsWithScroll() {
var dims = this.dimensions;
var lastViewportLeft = dims.viewportLeft;

dims.sidebarLeft = StickySidebar.offsetRelative(this.sidebar).left;

Expand All @@ -313,12 +314,16 @@
if (dims.topSpacing < dims.lastTopSpacing) {
dims.translateY += dims.lastTopSpacing - dims.topSpacing;
this._reStyle = true;
} else if (lastViewportLeft !== dims.viewportLeft) {
this._reStyle = true;
}
} else if ('VIEWPORT-BOTTOM' === this.affixedType) {
// Adjust translate Y in the case decrease bottom spacing value.
if (dims.bottomSpacing < dims.lastBottomSpacing) {
dims.translateY += dims.lastBottomSpacing - dims.bottomSpacing;
this._reStyle = true;
} else if (lastViewportLeft !== dims.viewportLeft) {
this._reStyle = true;
}
}

Expand Down Expand Up @@ -433,7 +438,7 @@
left: dims.sidebarLeft - dims.viewportLeft, width: dims.sidebarWidth };
break;
case 'VIEWPORT-BOTTOM':
style.inner = { position: 'fixed', top: 'auto', left: dims.sidebarLeft,
style.inner = { position: 'fixed', top: 'auto', left: dims.sidebarLeft - dims.viewportLeft,
bottom: dims.bottomSpacing, width: dims.sidebarWidth };
break;
case 'CONTAINER-BOTTOM':
Expand Down Expand Up @@ -465,6 +470,7 @@
if (this._breakpoint) return;

force = this._reStyle || force || false;
this._reStyle = false;

var offsetTop = this.options.topSpacing;
var offsetBottom = this.options.bottomSpacing;
Expand Down
Loading