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 drag and drop an image to canvas #76

Open
tabishmirza opened this issue Jul 21, 2020 · 1 comment
Open

How to drag and drop an image to canvas #76

tabishmirza opened this issue Jul 21, 2020 · 1 comment

Comments

@tabishmirza
Copy link

tabishmirza commented Jul 21, 2020

Hi Muaz,

First of all, thanks for the great library. I have been trying to drag and drop images on the canvas but canvas behavior is weird.
Here is what i am doing. i make the image dragable and then on "temp-canvas" drop event i execute the following code

        ev.preventDefault();

        var data = ev.dataTransfer.getData("icon-id");

        var x = ev.pageX;
        var y = ev.pageY;

        var image = document.getElementById(data);

        var points = [
            ['image', [image.src, x, y, image.width, image.height, 1],
                ['2', '#6c96c8', 'rgba(0,0,0,0)', '1', 'source-over', 'round', 'round', '15px "Arial"']
            ]
        ];

        designer.syncData({
            startIndex: designer.pointsLength,
            points: points
        });

this does not trigger my designer.addSyncListener callback. please help me with this

@tabishmirza
Copy link
Author

@muaz-khan please help me with this

Thanks

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

1 participant