Skip to content
Open
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
10 changes: 10 additions & 0 deletions src/Sticky.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ let M;
let scrollDelta = 0;
let win;
let winHeight = -1;
let resizeObserver;

class Sticky extends Component {
constructor(props, context) {
Expand Down Expand Up @@ -98,6 +99,15 @@ class Sticky extends Component {
if (!this.bottomBoundaryTarget) {
this.bottomBoundaryTarget = doc.querySelector(boundary);
}
if (this.bottomBoundaryTarget) {
if (!resizeObserver) {
resizeObserver = new ResizeObserver(() => {
this.updateInitialDimension();
this.update();
});
}
resizeObserver.observe(this.bottomBoundaryTarget);
}
boundary = this.getTargetBottom(this.bottomBoundaryTarget);
}
return boundary && boundary > 0 ? boundary : Infinity;
Expand Down