From 979c65e781fe466bf347cf519a459a04d1c1b8cd Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Fri, 24 Oct 2025 17:40:50 +0530 Subject: [PATCH] modified logic in ocr --- .../views/fields/camera-capture.blade.php | 55 ++++++++----------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/resources/views/fields/camera-capture.blade.php b/resources/views/fields/camera-capture.blade.php index 72b3227..0ef9b2a 100644 --- a/resources/views/fields/camera-capture.blade.php +++ b/resources/views/fields/camera-capture.blade.php @@ -328,42 +328,35 @@ function cameraCapture() { }, - async capturePhoto() { - const video = this.$refs.video; - const canvas = this.$refs.canvas; - const ctx = canvas.getContext('2d'); - - canvas.width = video.videoWidth; - canvas.height = video.videoHeight; - ctx.drawImage(video, 0, 0); - - const snapshot = this.$refs.snapshot; - snapshot.src = canvas.toDataURL('image/png'); - snapshot.onload = () => { - snapshot.classList.remove('hidden'); - video.classList.add('hidden'); + snapshot.classList.remove('hidden'); + video.classList.add('hidden'); - this.photoTaken = true; - this.stopCamera(); + this.stopCamera(); - if (this.cropper) this.cropper.destroy(); + // Destroy old cropper if exists + if (this.cropper) this.cropper.destroy(); - requestAnimationFrame(() => { - this.cropper = new Cropper(snapshot, { - aspectRatio: NaN, - dragMode: 'crop', - viewMode: 1, - autoCropArea: 0.9, - background: true, - responsive: true, - movable: true, - zoomable: true, - }); - console.log("✅ Cropper initialized"); + // Initialize cropper + requestAnimationFrame(() => { + this.cropper = new Cropper(snapshot, { + aspectRatio: NaN, + dragMode: 'crop', + viewMode: 1, + autoCropArea: 0.9, + background: true, + responsive: true, + movable: true, + zoomable: true, }); - }; -} + console.log("✅ Cropper initialized"); + + // ✅ Update Alpine reactivity so buttons show + this.$nextTick(() => { + this.photoTaken = true; + }); + }); +}, // async uploadCroppedImage() {