Croppie
Croppie copied to clipboard
`croppie.destroy()` causes errors
Error 1
// This error happens because `opts.update()` is called after `destroy()`
Uncaught (in promise) TypeError: Cannot read property 'preview' of undefined
at Croppie._get (webpack-internal:///223:1318:37)
at Croppie._result (webpack-internal:///223:1353:25)
at Croppie.result (webpack-internal:///223:1569:28)
Error 2
// This error happens because `_updateOverlay()` is triggered by `_debouncedOverlay()`
// after a `destroy()`, and `self.elements` is null
Uncaught TypeError: Cannot read property 'boundary' of undefined
at Croppie._updateOverlay (croppie.js?f101:939)
at later (croppie.js?f101:102)
function _updateOverlay() {
var self = this,
boundRect = self.elements.boundary.getBoundingClientRect(),
imgData = self.elements.preview.getBoundingClientRect();
...
}
Good catch. I guess the simplest fix would be adding a
if (!self.elements) return;
at the top of the _updateOverlay.
Yes, shall I do that and submit a PR?
Will that fix the first error though?
I'm not seeing the first error you mentioned. Where is opts.update called after destroy?
Hmm I can't replicate this atm, but possibly if the croppie was destroyed while waiting for loadImage()
in _bind()
?
Then _triggerUpdate()
is called after croppie has been destroyed, which calls self.options.update()
Despite using this if (!self.elements) return; at the top of _updateOverlay(), I am getting the error "Cannot read property 'preview' of undefined" at Croppie_get().
and in Croppie_destroy(), I am getting this error when I am trying to destroy an existing instance post uploading an image.
Please guyz, Can you help me out asap. I am using it in my company project and deadline is this Sunday. Please have a look and comment to help.
Hey guyz, i was getting the error because _croppie_instance.destroy() was not working. Set it to null and then initiated Croppie instance and it started working.
I was encountering this because I had moved one of the Croppie components (the zoom slider) from the Croppie container into our container.
Calling destroy()
with some Croppie elements intentionally placed elsewhere in the DOM threw an error. It looked like Croppie was trying to search for known children and couldn't find them in the original parent container.
When I put the slider back into the original Croppie container, then proceed to can call destroy()
, the instance is destroyed without error.
Any fix on that?
Anybody fix on this problem?