wanadev / perspective.js

Transforms the perspective of an image and draw it on a canvas
Apache License 2.0
136 stars 27 forks source link

Created a component with perspective.js, but have problem onload #3

Closed gustavosapienza closed 8 years ago

gustavosapienza commented 8 years ago

Hi, how are you?

At the last time you help-me and saved my life, I need one more favor,

I created this script whiot this component: http://jsfiddle.net/gustavosapienza/7jv207ec/

But onload have a error, i need to load the page some times to run correctly the scripts, do you know whats happen? Only on Firefox is working

Thanks a lot!

flozz commented 8 years ago

Hello,

You have to wait for the images to be loaded before trying to transform / draw them:

var img = new Image();
img.onload = function (event) {
    // Code that use the image here...
};
img.src = "http://example.com/image.png";

http://jsfiddle.net/7jv207ec/1/


Please do not open issues for questions that are not related to the project itself. If you need help with Javascript, you can ask your questions on sites like StackOverflow.

gustavosapienza commented 8 years ago

Thanks flozz! You really helped me! Thanks a lot!