Skip to content
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

Feature request: DOM Event afterRender(ed) #1168

Open
tillias opened this issue Nov 10, 2020 · 6 comments
Open

Feature request: DOM Event afterRender(ed) #1168

tillias opened this issue Nov 10, 2020 · 6 comments

Comments

@tillias
Copy link

tillias commented Nov 10, 2020

Hello folks, it would be very nice having some event, which got fired right after rendering is completed.

As an alternative solution render some child element inside canvas, after all vertices and edges are rendered.

This is absolutely must have if you need some reliable automated visual tests (e.g. cypress / percy). At the moment the only solution is using timeouts

percy/percy-cypress#266 (comment)

@tillias tillias changed the title DOM Event afterRender Feature request: DOM Event afterRender(ed) Nov 10, 2020
@Thomaash
Copy link
Member

Hi @tillias,

there already is afterDrawing event. If you need it in DOM, you should be able to dispatch it with a simple one liner.

@tillias
Copy link
Author

tillias commented Nov 11, 2020

Hi @Thomaash, that was also my first idea after reading https://visjs.github.io/vis-network/docs/network/#Events. I have already tried rendering some div in DOM when event is fired and then taken screenshot of canvas. Result was that div was present inside DOM, but rendering was still in progress: https://percy.io/bb9225f6/microservice-catalog/builds/7648382 . Left image is what I see if timeout is used, right image is what is available after afterDrawing has fired

Is there any debug / logging available, so I can further check this afterDrawing ?

@Thomaash
Copy link
Member

This looks like rendering is done but the network is not fitted into the canvas.

@tillias
Copy link
Author

tillias commented Nov 11, 2020

The thing is, that the exactly the same configuration (random seed, resolution etc) is used. Difference is, that on the left side there is timeout set, before screenshot is taken and to the right there is no timeout but instead wait for afterDrawing event. I can live with timeout, but just curious what may be the reason and if there is any possibility to debug it

@Thomaash
Copy link
Member

I think, that the code you're using triggers more than just one rendering (animation will render multiple times, adding nodes will cause rerender, as will calling fit etc.). You react to the first of them and call it a day. With timeout though, you enter a race condition where it's very likely that all rendering is done, hence the different screenshots.

Try to log each afterDrawing event, I'm pretty sure there will be more than one.

PS: Keep in mind that this is just an educated guess based on two screenshots and very little insight into your test procedure.

@tillias
Copy link
Author

tillias commented Nov 12, 2020

I think I have found an issue and even reproduced it locally. So if I click "resize to window" and then restore back the tab then afterDraw is fired 3-5 times.

After that content always too big to fit:

image
image

Is it a known issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants