Skip to content

Commit

Permalink
[FEATURE] Improve scroll on resize handler (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lemick authored Dec 8, 2024
1 parent c572946 commit 435ca0d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/api-resize-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import type { ResizeContext } from "~/type";
/**
* Resize handler that scrolls to restore the iframe's position in the viewport as it was before the resize.
*
* *Note:* This behavior only triggers if the iframe is currently being hovered by the user,
* *Note:* This behavior only triggers if the iframe currently has focus,
* in order to try to limit the number of scroll as it can affect the user experience.
*/
export const updateParentScrollOnResize = ({ previousRenderState, nextRenderState, interactionState }: ResizeContext) => {
if (interactionState.isHovered) {
export const updateParentScrollOnResize = ({ previousRenderState, nextRenderState, iframe }: ResizeContext) => {
if (document.activeElement === iframe) {
window.scrollBy(0, nextRenderState.rect.bottom - previousRenderState.rect.bottom);
}
};

0 comments on commit 435ca0d

Please sign in to comment.