Skip to content

Commit

Permalink
Support passing options to resize action
Browse files Browse the repository at this point in the history
  • Loading branch information
techniq committed Jul 9, 2024
1 parent 7fb54a9 commit c5de38c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-bats-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte-ux': patch
---

Support passing `options` to resize action
4 changes: 2 additions & 2 deletions packages/svelte-ux/src/lib/actions/observer.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { Action } from 'svelte/action';

export const resize: Action<Element> = (node) => {
export const resize: Action<Element, ResizeObserverOptions | undefined> = (node, options) => {
let observer = new ResizeObserver((entries, observer) => {
entries.forEach((entry) => {
node.dispatchEvent(new CustomEvent('resize', { detail: entry }));
});
});
observer.observe(node);
observer.observe(node, options);

return {
destroy() {
Expand Down

0 comments on commit c5de38c

Please sign in to comment.