-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds resize observer functionality #5963
Conversation
Implements ResizerObserver per @Rich-Harris sveltejs#5524 (comment) Done poorly, looking for guidance on doing this correctly or for someone else to take it on.
If nobody has a better way to implement this, should we call it good? Tests are passing. 🙂 |
looks okay to me in general. is there a test for this? eg: for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what happened with that package.lock.json
but I think its changed contents need to be omitted from this PR
Yeah, I reverted this. Good call. Thanks! |
Hi Team, thanks for the svelte 🙌 and for everything. I am new to the codebase, can anyone suggest to me what else needs to be done, so that I can take this MR from here and update the PR. I have added the test on top of @jacwright commits and rebased it locally, @dummdidumm if there is no issue can I push that commit here for your review? |
Any news on this? |
@205g0 I've planned to bring this up in the next maintainer's meeting. |
Just pushed some changes, but still a WIP. The bindings doesn't seem to work yet. |
Found an issue with resize observer bindings. If we're using |
I read on MDN that contentRect may be deprecated in the future. Perhaps we leave that one out? We could have And thank you for helping @bluwy! |
I saw that too but left it in since it has better browser support, but then it would be confusing to coexist with contentBoxSize. I can remove
I'm not sure if this is safe since I'll bring this up in the maintainer's meeting. |
Update from the last maintainer's meeting, we had decided to leave the variable as What's left on this PR is to clean it up, tests, and docs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and yes, would love to see a unit test for this
if (renderer.options.dev) { | ||
block.chunks.mount.push( | ||
b`${resize_observer} = @add_resize_observer_dev(${this.var}, ${callee}, { box: "${box}" });` | ||
); | ||
} else { | ||
block.chunks.mount.push( | ||
b`${resize_observer} = @add_resize_observer(${this.var}, ${callee}, { box: "${box}" });` | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you dont have to do this here, any runtime function suffixed with _dev
will be automatically used when the dev
mode is true
if (renderer.options.dev) { | |
block.chunks.mount.push( | |
b`${resize_observer} = @add_resize_observer_dev(${this.var}, ${callee}, { box: "${box}" });` | |
); | |
} else { | |
block.chunks.mount.push( | |
b`${resize_observer} = @add_resize_observer(${this.var}, ${callee}, { box: "${box}" });` | |
); | |
} | |
block.chunks.mount.push( | |
b`${resize_observer} = @add_resize_observer(${this.var}, ${callee}, { box: "${box}" });` | |
); |
observer.observe(node, opts); | ||
return () => observer.disconnect(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wonder if we could / should reuse the ResizeObserver
instance
Thanks for the review @tanhauhau. I haven't been following up on this PR as well, so it has been stale for quite a while now. I'll try to pick it up soon, or if anyone feels like tackling this, feel free too. |
Closes #7583 |
are there plans to ever merge this PR? It looks like it would if the weird behavior of adding |
@searleser97 Feel free to pick up the remaining work to complete the PR. There were discussions above that weren't implemented yet, and I haven't had the need for this feature to continue working on it 😬 |
Closing in favor #8022 |
Implements ResizeObserver bindings: #5524 (comment) Continuation of: #5963 Related to #7583 --------- Co-authored-by: Simon H <[email protected]>
Implements ResizerObserver per @Rich-Harris #5524 (comment)
Done poorly, looking for guidance on doing this correctly or for someone else to take it on.
I started implementing this but it is stretching out too long. I haven't been in the code-base for a while and to add this a parameter needs to be added to the
resize_observer
function (the observer entries) so they can be set in the binding. I've got it working, but I believe my implementation is not clean. I wanted to publish what I had to save another time, but if I'm close then I'll fix it up with your direction.//CC @pushkine @iamricard