mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-02-22 22:23:03 +01:00
Fix race condition in CropperController
This commit is contained in:
parent
75a0702462
commit
3d21beff39
1 changed files with 12 additions and 8 deletions
|
@ -34,8 +34,7 @@ export default class extends Controller {
|
||||||
|
|
||||||
if (this.inputTarget.files && this.inputTarget.files[0]) {
|
if (this.inputTarget.files && this.inputTarget.files[0]) {
|
||||||
this.readImage(this.inputTarget.files[0], (src) => {
|
this.readImage(this.inputTarget.files[0], (src) => {
|
||||||
this.cropperTarget.src = src;
|
this.cropperTarget.addEventListener('load', () => {
|
||||||
|
|
||||||
new Croppr(this.cropperTarget, {
|
new Croppr(this.cropperTarget, {
|
||||||
aspectRatio: parseFloat(this.aspectRatioValue),
|
aspectRatio: parseFloat(this.aspectRatioValue),
|
||||||
startSize: [100, 100, '%'],
|
startSize: [100, 100, '%'],
|
||||||
|
@ -43,6 +42,11 @@ export default class extends Controller {
|
||||||
onCropMove: this.updateValues.bind(this),
|
onCropMove: this.updateValues.bind(this),
|
||||||
onCropEnd: this.updateValues.bind(this)
|
onCropEnd: this.updateValues.bind(this)
|
||||||
});
|
});
|
||||||
|
}, {
|
||||||
|
once: true
|
||||||
|
});
|
||||||
|
|
||||||
|
this.cropperTarget.src = src;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue