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

Problem with draggable #169

Closed
vpascoal opened this issue Nov 27, 2014 · 4 comments
Closed

Problem with draggable #169

vpascoal opened this issue Nov 27, 2014 · 4 comments

Comments

@vpascoal
Copy link

Hi!

In this example why jcanvas adds three images?

If I set draggable to false it doesn't add.
And something weird happens too when I mouseover canvas. (one of the images changes its position in the stack)

Am I missing something?

What I want is to zoom in/out an image in canvas by having two buttons. But when I click in one of the buttons, the image gets repeated inside the canvas

Thank you

@caleb531
Copy link
Owner

Set layer: true in addition to draggable: true/false and you should be good to go. Draggable drawings are implicitly layers but non-draggable drawings must be made layers via layer: true. I recommend always setting layer: true for drawings in jCanvas.

Caleb

@vpascoal
Copy link
Author

Hi!

Thank you but even setting layer: true doesn't work.

@caleb531
Copy link
Owner

The images will be repeated upon clicking the button because because calling drawImage() with layer: true will create a new image layer on the canvas. The only exception is if you've specified a unique name for that image, and a layer with that name already exists.

As for the position change, images in jCanvas are drawn asynchronously, and so the point at which your image is drawn depends on when the image loads (and that in itself depends on many other factors). Fortunately, calling drawLayers() after adding your image layers should do the trick. In fact, I also recommend calling addLayer() with type: 'image' instead of calling drawImage() to reduce ambiguity.

@vpascoal
Copy link
Author

Your advices guided me to this:

http://jsfiddle.net/vpascoal/j9kja28L/

Thank you

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