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

How to detect target object on drag drop operation on image with zoom and scrolled canvas? #2416

Closed
BharatPatel1 opened this issue Aug 12, 2015 · 9 comments
Assignees

Comments

@BharatPatel1
Copy link

As on canvas there are some images added. Let say image a, b and c at different position. If Zoom in the canvas and due to overflow scroll it and after that when I try to drag drop an library image -x on the canvas image -a, then by using 'findTarget' unable to get the target image-a on canvas.

var target = canvas.findTarget(event.e);

Facing the problem with zoom + scroll combination.

Thanks for any help!

@asturur
Copy link
Member

asturur commented Aug 12, 2015

Please provide a jsfiddle with this setup
( 3 images, scroll e zoomed canvas )

@BharatPatel1
Copy link
Author

Thank you Andrea,

Please refer the jsfiddle:

http://jsfiddle.net/bharatpatel/w72pxr6d/1/

@asturur
Copy link
Member

asturur commented Aug 12, 2015

Please let me understand better.
In this example there a picture.
When there are 2 images, and secondo image goes over the first, the first is no more selectable.
Is this the problem?
Or you are trying to do something with drag and drop from outside the canvas?

@BharatPatel1
Copy link
Author

Yes, I have draged image from out side the canvas and drop the image on canvas image. And to replace the canvas image by the dragged image trying to detect canvas image object on drop event using mouse pointer.

@asturur
Copy link
Member

asturur commented Aug 12, 2015

if you can click the image it means that findTarget is working good.
can you share your dragndrop code, maybe there is some issue there.

@BharatPatel1
Copy link
Author

Without zoom and scroll of the page operations, on the drop event findTarget working fine.

But before performing drag drop operation if we perform

  1. zoom the canvas upto the image gose outoff the div or canvas visible screen.

  2. scroll the page so the canvas image viewable area of the div ( let say scroll upto the canvas image near to topbar of the canvas).

  3. now perform drag drop event and on drop event findTarget not working.

(Sorry dear as currently I am replying from mobile... I am not on development environment at this time. I am unable to share the reference code at this time.

@BharatPatel1
Copy link
Author

Please refer with drag drop operation:

http://jsfiddle.net/w72pxr6d/2/

@asturur
Copy link
Member

asturur commented Aug 13, 2015

Look there is some strange interaction between viewportzoom and calcOffset with scrolling.
I do not know if IFRAME is the problem

Anyway in fiddle i changed just this:

function handleDragEnd(event) {
    //removed event.e
    console.log(event);
    var pointer = _canvas.getPointer(event);
    console.log(pointer);
    var targetObject = _canvas.findTarget(event);
    console.log("target object : " + targetObject )
}

https://jsfiddle.net/w72pxr6d/3/embedded/result/
if you run it in the jsfiddle space divided in 4 frames it never works

@BharatPatel1
Copy link
Author

I was also in same impression that IFRAME is the problem. so i had tried it in single page app. However, facing the same problem.

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

No branches or pull requests

2 participants