cstefanache / angular2-img-cropper

Angular 2 Image Cropper
MIT License
364 stars 135 forks source link

Have an issue with dynamic sizing not being defined :S #216

Open avvie opened 6 years ago

avvie commented 6 years ago

The component works fine generally, i love it. When i route to a page that has it i get the following error in console. But if i refresh it works fine

Unhandled Promise rejection: Cannot read property 'dynamicSizing' of undefined ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot read property 'dynamicSizing' of undefined
    at ImageCropperComponent.webpackJsonp.../../../../ng2-img-cropper/src/imageCropperComponent.js.ImageCropperComponent.ngOnDestroy (imageCropperComponent.js:46)

Any ideas ?

avvie commented 6 years ago

after some fiddling around. i got rid of that initial error. by removing a promise in the constructor that checked if the user is logged in . if he wasnt it would route to the root page. But now the same behavior but different error

ERROR TypeError: Cannot read property 'onMouseMove' of undefined
    at ImageCropperComponent.webpackJsonp.../../../../ng2-img-cropper/src/imageCropperComponent.js.ImageCropperComponent.onMouseMove (imageCropperComponent.js:75)
    at Object.eval [as handleEvent] (ImageCropperComponent.html:7)
    at handleEvent (core.es5.js:11995)
    at callWithDebugContext (core.es5.js:13456)
    at Object.debugHandleEvent [as handleEvent] (core.es5.js:13044)
    at dispatchEvent (core.es5.js:8599)
    at core.es5.js:9210
    at HTMLCanvasElement.<anonymous> (platform-browser.es5.js:2668)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:424)
    at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (zone.js:191)
Zoly90 commented 6 years ago

Hy guys,

I have just encountered this issue with the following scenario: navigating to 'my profile' page (where the image cropper component is), in my project, after that going to another page and trying to go back to 'my profile' and there was the error/bug.

I succeeded to resolve it until now, by putting a condition on the container which holds the *ngIf="data.image"