Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return;
}
const [x, y] = this._windowScrollTarget;
window.scrollTo(x, y);
++this._numWindowScrollAttempts;
/* istanbul ignore if: paranoid guard */
if (this._numWindowScrollAttempts >= MAX_SCROLL_ATTEMPTS) {
this._windowScrollTarget = null;
return;
}
this._checkWindowScrollHandle =
requestAnimationFrame(this._checkWindowScrollPosition);
};
}
queueClassAndNode(className, node) {
this.classNameAndNodeQueue.push({
className,
node,
})
if (!this.rafHandle) {
// The first animation frame is skipped when starting new transitions since
// entering absolutely positioned elements in Chrome does not animate otherwise.
this.rafHandle = raf(() => this.flushClassNameAndNodeQueueOnNextFrame())
}
}
if (!scrollTarget) {
return
}
const [ x, y ] = scrollTarget
window.scrollTo(x, y)
++numScrollAttempts
/* istanbul ignore if: paranoid guard */
if (numScrollAttempts >= MAX_SCROLL_ATTEMPTS) {
scrollTarget = null
return
}
checkScrollHandle = requestAnimationFrame(checkScrollPosition)
}
function onScroll() {
if (savePositionHandle !== null) {
return
}
// It's possible that this scroll operation was triggered by what will be
// a `POP` transition. Instead of updating the saved location
// immediately, we have to enqueue the update, then potentially cancel it
// if we observe a location update.
savePositionHandle = requestAnimationFrame(() => {
savePositionHandle = null
const state = readState(currentKey)
const scrollPosition = [ scrollLeft(window), scrollTop(window) ]
// We have to directly update `DOMStateStorage`, because actually
// updating the location could cause e.g. React Router to re-render the
// entire page, which would lead to observably bad scroll performance.
saveState(currentKey, { ...state, scrollPosition })
})
}
return new Promise(resolve => {
this._checkWindowScrollHandle = requestAnimationFrame(() =>
resolve(this._checkWindowScrollPosition()),
);
});
};
queueClassAndNode(className, node) {
this.classNameAndNodeQueue.push({
className,
node,
});
if (!this.rafHandle) {
this.rafHandle = raf(() => this.flushClassNameAndNodeQueue());
}
}
flushClassNameAndNodeQueueOnNextFrame() {
this.rafHandle = raf(() => this.flushClassNameAndNodeQueue())
}
enqueueHeightTransition() {
if (!this.rafHandle) {
this.rafHandle = raf(this.performHeightTransition)
}
}