-
Notifications
You must be signed in to change notification settings - Fork 27
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
Moving content breaks perimeter #9
Comments
Thanks for the issue @JulienPradet! You bring up a great point, current
As far as I know,
I like the idea of letting users decide when the bounds should be recalculated, but that still seems difficult if some change in a separate part of the render tree is affecting the element's position. It could be difficult and tedious if you have a handful of perimeters drawn on the screen and you have to manually consider all cases where the layout changes. That's a tough problem, I'm not totally sure what the best approach is yet!
Great idea! |
Actually, the reason why I talked about However, if we use I'll get a demo out first in order to check what I'm saying. But I'd expect the event loop stack not to impact the layout/painting process. <edit>Oh, you tweeted about it ^^</edit>
Yup, that's the curse of manual checking. I'll first try to land a PR with the automatic update thing mentioned above, if that's fine for you. Maybe things will be clearer in my head by then. Finally, about the onHover thing, I'll land a seperate PR for it. |
Here are 4 timelines demonstrating the difference between without debouncewith a 100ms debouncerequestAnimationFrame : (the drop at 2000ms is just a random one I guess) Demo code can be found here https://github.com/JulienPradet/react-perimeter/blob/master/src/index.js#L116 |
@aweary Thanks for this awesome lib, and thank you @JulienPradet for trying to fix this issue. I wanted to use Would be great to hear any update on this. Thanks again ✌️ |
Hi @yasserkaddour, I haven't gone any farther since I didn't know if my suggested solution would be merged (for lib size + lib goals reasons). Plus, there are two solutions that I can think of and didn't know which one to implement since having both might be useful. |
I managed to make it work by re-rendering the perimeter after each payload. But it would be great if this was supported out of the box. Julien, merci pour la contribution. |
I'm really hesitant to implement a solution that involves constantly redrawing the boundaries (even if it's debounced). Ideally, there would be a way for the application to tell We could:
import { Perimeter, redraw } from 'react-perimeter'
// Render a Perimeter with a name attribute
<Periemeter name="card" />
// Somewhere else, call redraw with the name
redraw("card");
// Or even call it without a name to redraw all perimeter instances
redraw();
|
Hi,
First of all, thanks for the lib. It's simple but smart!
However, one of my concerns is that when the content is moving, it actually breaks the perimeter since
this.bounds
is not updated. (I've checked the ongoing PRs and they dont seem to address this problem)The resize window event is a first step but is not enough.
I originally thought about adding the componentDidUpdate lifecycle method but if the updated content is not in the component itself it won't solve the issue (see updated demo in my fork https://github.com/JulienPradet/react-perimeter).
One way, though, to address this problem would be to update bounding shapes using a requestIdleCallback (in order to avoid freezing important stuff going on) and debouncing it (since the mouse's movements fire a lot of events) directly. This would be doable in the provider that will land in @jnsdls 's PR. This solution allows people not to think about updating their shapes and keeps the API simple. However it might lead to performance issues since there would be ton of updates.
If people want a more manual way to update those, the automatic update could be disabled and the update method could be exposed in the context in order for them to call it in their own component lifecycles.
If what I'm talking about is not in the scope of the lib, feel free to ignore it.
Additionnally, if what I'm saying is not clear enough I could land a POC if you're interested in it.
👋
Edit: Oh, and thinking about it, the perimeter could check the hover event on the registered DOM node too! This way, even if the perimeter is broken, the preload would still launches on hover which is still nice to have. 🙂
The text was updated successfully, but these errors were encountered: