-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(renderer): resize chart on resizing root element
- Loading branch information
1 parent
a023795
commit daec0cd
Showing
3 changed files
with
28 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { createRenderer } from './create-renderer'; | ||
export { createResizeObserver } from './resize-observer'; | ||
export { elements } from './elements'; | ||
export { rendererSubscriber } from './renderer-subscriber'; | ||
export type { Renderer } from './renderer.models'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export function createResizeObserver(resizeFn: () => void) { | ||
if (window.ResizeObserver && window.requestAnimationFrame) { | ||
return new ResizeObserver((entries) => { | ||
window.requestAnimationFrame((): void | undefined => { | ||
if (!entries?.length) return; | ||
resizeFn(); | ||
}); | ||
}); | ||
} | ||
return { | ||
observe: () => { | ||
window.addEventListener('resize', resizeFn); | ||
}, | ||
unobserve: () => { | ||
window.removeEventListener('resize', resizeFn); | ||
}, | ||
}; | ||
} |