pwambach / angular-canvas-painter

Angular.js directive to paint on a canvas on desktop or touch devices
MIT License
116 stars 35 forks source link

pw-canvas Not Loading Sometimes #13

Closed mario-aleo closed 8 years ago

mario-aleo commented 9 years ago

Hello,

I'm getting an odd error that sometimes, when the page is loaded, the pw-canvas src element is not loaded. My pw-canvas is under a ui-route template. Someone have any ideia about why this is not working properly?

Thanks.

pwambach commented 9 years ago

Hey, do you mean the 'imageSrc' background image is not loaded? Or is the whole directive not working? In general the directive shouldn't be affected by the ui-router. Could you provide an example to reproduce?

mario-aleo commented 9 years ago

I've analyzed it better, the directive is been load, but the imageSrc element is not. Here's the case:

 <md-whiteframe class="md-whiteframe-z4" layout layout-align="center center" style="width: 90%; height: 85%;">
    <div id="canv" style="width: 90%; height: 85%; overflow: scroll;" layout="column" layout-align="center center">
        <div pw-canvas options="option"></div>
    </div>
</md-whiteframe>

Where the option is:

$scope.option = { imageSrc: 'img/DocumentIcon.jpg', lineWidth: 1};

I've notice that when the page is load, the imageSrc is not loaded, but when I reload the page by:

$scope.reload = function(){
    $state.go($state.current, {}, {reload: true});
};

The ImageSrc element is load correctly.

It's not a hell problem once that this app will load a selected image, and in this case, that the element is just reloaded, it works fine. Anyway, I would like to make it work that way to have a default ImageSrc as background until the user select an image.

Thanks for answering.

pwambach commented 9 years ago

Hey,

i tried a simple example using ui-router, the background image shows up everytime the view is loaded. Do you have your code online? Or can you check if the image loaded callback (https://github.com/pwambach/angular-canvas-painter/blob/master/js/pwCanvas.js#L38) is executed after the directives link function did run?