canvasframework 0.5.54 → 0.5.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/QRCodeReader.js +25 -1
- package/package.json +1 -1
|
@@ -53,7 +53,8 @@ class QRCodeReader extends Component {
|
|
|
53
53
|
async _mount() {
|
|
54
54
|
super._mount?.();
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
// ✅ CORRECTION : Ne démarrer que si visible ET pas en navigation
|
|
57
|
+
if (this.visible && this.autoStart && !this.stream && !this.isStarting && !this.framework._isNavigating) {
|
|
57
58
|
this.isStarting = true;
|
|
58
59
|
await this.startCamera();
|
|
59
60
|
this.isStarting = false;
|
|
@@ -61,6 +62,12 @@ class QRCodeReader extends Component {
|
|
|
61
62
|
|
|
62
63
|
this.setupEventListeners();
|
|
63
64
|
}
|
|
65
|
+
|
|
66
|
+
onUnmount() {
|
|
67
|
+
this.stopScanning();
|
|
68
|
+
this.removeEventListeners();
|
|
69
|
+
this.stopCamera();
|
|
70
|
+
}
|
|
64
71
|
|
|
65
72
|
destroy() {
|
|
66
73
|
this.stopScanning();
|
|
@@ -87,6 +94,22 @@ class QRCodeReader extends Component {
|
|
|
87
94
|
document.head.appendChild(script);
|
|
88
95
|
}
|
|
89
96
|
}
|
|
97
|
+
|
|
98
|
+
static cleanupAllQRReaders() {
|
|
99
|
+
const allVideos = document.querySelectorAll('video');
|
|
100
|
+
allVideos.forEach(video => {
|
|
101
|
+
if (video.srcObject) {
|
|
102
|
+
const stream = video.srcObject;
|
|
103
|
+
if (stream && stream.getTracks) {
|
|
104
|
+
stream.getTracks().forEach(track => track.stop());
|
|
105
|
+
}
|
|
106
|
+
video.srcObject = null;
|
|
107
|
+
}
|
|
108
|
+
if (video.parentNode) {
|
|
109
|
+
video.parentNode.removeChild(video);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
90
113
|
|
|
91
114
|
setupEventListeners() {
|
|
92
115
|
this.onTouchStart = this.handleTouchStart.bind(this);
|
|
@@ -126,6 +149,7 @@ class QRCodeReader extends Component {
|
|
|
126
149
|
}
|
|
127
150
|
|
|
128
151
|
async startCamera() {
|
|
152
|
+
QRCodeReader.cleanupAllQRReaders();
|
|
129
153
|
if (this.stream) return;
|
|
130
154
|
|
|
131
155
|
try {
|