Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onUpdate = () => {
if (!this._isMounted) {
return
}
const { offsetTop, viewportOffsetTop } = this.props
const scrollTop = getScrollTop(ownerWindow(this))
const positionTopMin = scrollTop + (viewportOffsetTop || 0)
if (positionTopMin <= offsetTop) {
this.updateState('top', null, null)
return
}
if (positionTopMin > this.getPositionTopMax()) {
if (this.state.affixed === 'bottom') {
this.updateStateAtBottom()
} else {
// Setting position away from `fixed` can change the offset parent of
// the affix, so we can't calculate the correct position until after
// we've updated its position.
this.setState(
{
if (typeof target === 'string') {
const targetElement =
document.getElementById(target) ||
document.getElementsByName(target)[0];
if (targetElement) {
targetElement.scrollIntoView();
return;
}
// Fallback to scrolling to top when target fragment doesn't exist.
target = [0, 0]; // eslint-disable-line no-param-reassign
}
const [left, top] = target;
scrollLeft(element, left);
scrollTop(element, top);
}
}
() => {
expect(scrollTop(window)).to.equal(15000);
done();
},
];
() => {
scrollTop(window, 15000);
delay(() => history.push('/page2'));
},
() => {
function getContainerDimensions(containerNode) {
let width, height, scroll;
if (containerNode.tagName === 'BODY') {
width = window.innerWidth;
height = window.innerHeight;
scroll =
getScrollTop(ownerDocument(containerNode).documentElement) ||
getScrollTop(containerNode);
} else {
({ width, height } = getOffset(containerNode));
scroll = getScrollTop(containerNode);
}
return { width, height, scroll};
}
_savePosition(key, element) {
this._stateStorage.save(this._getCurrentLocation(), key, [
scrollLeft(element),
scrollTop(element),
]);
}
function onScroll() {
if (!scrollTarget) {
return
}
const [ xTarget, yTarget ] = scrollTarget
const x = scrollLeft(window)
const y = scrollTop(window)
if (x === xTarget && y === yTarget) {
scrollTarget = null
cancelCheckScroll()
}
}
function getContainerDimensions(containerNode) {
let width, height, scroll;
if (containerNode.tagName === 'BODY') {
width = window.innerWidth;
height = window.innerHeight;
scroll =
getScrollTop(ownerDocument(containerNode).documentElement) ||
getScrollTop(containerNode);
} else {
({ width, height } = getOffset(containerNode));
scroll = getScrollTop(containerNode);
}
return { width, height, scroll};
}