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

Stop Render on Mouse Events #5253

Closed
DylanPaulusSEL opened this issue Sep 21, 2018 · 7 comments · Fixed by #5256
Closed

Stop Render on Mouse Events #5253

DylanPaulusSEL opened this issue Sep 21, 2018 · 7 comments · Fixed by #5256
Labels

Comments

@DylanPaulusSEL
Copy link
Contributor

While using a canvas with a lot of shapes, we'd like to disable the rendering the occurs when clicking on an object -- while still being able to click on a shape and get it's information (ie. staticCanvas won't work). Tried turning off selection and AddOrRemoveShape, but the mouse events seem to still fire a render. Is there a way to capture the mouse event, but prevent fabric from performing a rerender? Or can turning off selection for the whole canvas stop the rerender?

Version

2.3.5

Steps to reproduce

n/a

Expected Behavior

Add ability to turn off mouse down/up rendering if selection + AddOrRemoveShape is disabled

Actual Behavior

image

@asturur
Copy link
Member

asturur commented Sep 21, 2018

The code shown is for the spraybrush, that is active just on the spray brush usage.

For general mouse events you get render generally when they are needed. So selecting a shape requires drawing controls and you need a render ( moving controls somewherelse is a future thing to do )

Not having selection active should not render indeed.

@DylanPaulusSEL
Copy link
Contributor Author

@asturur Whoops, followed the wrong code. 😄

So for the canvas I'm setting renderOnAddRemove: false & selection: false,. For each object I apply

selectable = false,
hasBorders = false,
lockMovementX = true;
lockMovementY = true;
lockScalingX = true;
lockScalingY = true;
lockUniScaling = true;
lockRotation = true;
editable = false;
hasRotatingPoint = false;
hasControls = false;

And I still see a render when I select an object/group. Added a gif below where I added a console.log every time renderAll is called in Fabric (The selection being shown is done in the DOM, outside of Fabric). Is something missing?
rot

@asturur
Copy link
Member

asturur commented Sep 21, 2018

if only mousedown and mouse events are fired, no it should not render. If you can reproduce in a fiddle we can mark it as a bug

@DylanPaulusSEL
Copy link
Contributor Author

http://jsfiddle.net/Da7SP/3045/

Here is a fiddle reproducing. Every time a click happens in the canvas, it'll show a render, clicking the group shows two renders.

@asturur
Copy link
Member

asturur commented Sep 22, 2018

Definitely a bug. There is code in fabricjs to render just when necessary, we broke it somehow.

We need some sort of interaction tests that can catch those things, i tried to build a lib but is not really easy to have something that will work in node and browsers under qunit.

@asturur
Copy link
Member

asturur commented Sep 22, 2018

FIY if you want to check the PR
#5256

The logic was very old and untouched, i had no way to figure out when it broke, i hope this logic is more clear and more easy to read and check what it should do.

Another thing, a quick and easy way to see if the canvas is rendering is to use:

canvas.on('after:render', console.trace) so you know what is calling which kind of render ( top or down )

@ganderzz
Copy link

FIY if you want to check the PR
#5256

The logic was very old and untouched, i had no way to figure out when it broke, i hope this logic is more clear and more easy to read and check what it should do.

Another thing, a quick and easy way to see if the canvas is rendering is to use:

canvas.on('after:render', console.trace) so you know what is calling which kind of render ( top or down )

👏 That was fast! Thanks for the tip, this is awesome!

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

Successfully merging a pull request may close this issue.

3 participants