user3470138
user3470138

Reputation: 55

DOM event function very slow in paper.js

Connecting the event of dom elements with paper.js object. its working fine. but its executing function very slow.

ex:

<button id="btn">Click</button>  

js'

var secondPath = new Path.Circle(new Point(180, 50), 35);

$('#btn').on('click', function(e){
   secondPath.fillColor = 'blue';
});

here getting the results but it takes little time. But its working, if I add the event in the canvas elements

Please help me

Upvotes: 1

Views: 405

Answers (1)

bmacnaughton
bmacnaughton

Reputation: 5308

I believe the issue is that you're using the DOM events, not the paperjs mouse handlers. When you use the paperjs mouse handling it notes whether the canvas needs to be redrawn. When you use the DOM mouse events paper doesn't "know" you've changed the content so it doesn't force an update to the view.

Add a line: paper.view.update() after you fill the circle and things should work correctly.

Upvotes: 3

Related Questions