canvasframework 0.5.11 → 0.5.13
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/core/CanvasFramework.js +84 -17
- package/index.js +1 -1
- package/package.json +1 -1
package/core/CanvasFramework.js
CHANGED
|
@@ -1932,16 +1932,37 @@ class CanvasFramework {
|
|
|
1932
1932
|
// ✅ OPTIONNEL : Marquer les composants comme "dirty" pour forcer le rendu
|
|
1933
1933
|
this._maxScrollDirty = true;
|
|
1934
1934
|
|
|
1935
|
-
|
|
1935
|
+
// ✅ ARRÊTER LES CAMÉRAS DES ANCIENS COMPOSANTS
|
|
1936
|
+
oldComponents.forEach(comp => {
|
|
1936
1937
|
// Vérifier si c'est un composant caméra
|
|
1937
|
-
if (comp.constructor.name === 'FloatedCamera' ||
|
|
1938
|
+
if (comp.constructor.name === 'FloatedCamera' ||
|
|
1939
|
+
comp.constructor.name === 'Camera' ||
|
|
1940
|
+
comp.constructor.name === 'QRCodeReader') {
|
|
1938
1941
|
// Arrêter le stream vidéo
|
|
1939
1942
|
if (comp.stopCamera && typeof comp.stopCamera === 'function') {
|
|
1940
1943
|
comp.stopCamera();
|
|
1941
|
-
console.log(`🎥 Caméra ${comp.constructor.name} arrêtée avant navigation`);
|
|
1942
1944
|
}
|
|
1943
1945
|
}
|
|
1944
1946
|
});
|
|
1947
|
+
|
|
1948
|
+
// ✅ NOUVEAU : Vérifier si la nouvelle route contient des composants caméra
|
|
1949
|
+
const hasCamera = this.components.some(comp =>
|
|
1950
|
+
comp.constructor.name === 'FloatedCamera' ||
|
|
1951
|
+
comp.constructor.name === 'Camera' ||
|
|
1952
|
+
comp.constructor.name === 'QRCodeReader'
|
|
1953
|
+
);
|
|
1954
|
+
|
|
1955
|
+
// Si la nouvelle route N'A PAS de caméra, nettoyer toutes les vidéos après 3 secondes
|
|
1956
|
+
if (!hasCamera) {
|
|
1957
|
+
console.log('⏰ Nettoyage des vidéos programmé dans 3 secondes...');
|
|
1958
|
+
setTimeout(() => {
|
|
1959
|
+
const videos = document.querySelectorAll('video');
|
|
1960
|
+
videos.forEach(v => v.remove());
|
|
1961
|
+
}, 3000);
|
|
1962
|
+
} else {
|
|
1963
|
+
console.log('📹 Route avec caméra détectée, pas de nettoyage automatique');
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1945
1966
|
}
|
|
1946
1967
|
|
|
1947
1968
|
/**
|
|
@@ -2745,19 +2766,48 @@ class CanvasFramework {
|
|
|
2745
2766
|
renderSimpleTransition() {
|
|
2746
2767
|
const { progress, type, direction, oldComponents, newComponents } = this.transitionState;
|
|
2747
2768
|
|
|
2748
|
-
//
|
|
2749
|
-
const
|
|
2769
|
+
// Easing pour une animation plus fluide
|
|
2770
|
+
const eased = this.easeInOutCubic(progress);
|
|
2771
|
+
|
|
2750
2772
|
const directionMultiplier = direction === 'forward' ? 1 : -1;
|
|
2751
2773
|
|
|
2752
|
-
// Pour l'animation slide, dessiner seulement la nouvelle vue à la bonne position
|
|
2753
2774
|
if (type === 'slide') {
|
|
2754
|
-
//
|
|
2775
|
+
// ✅ AMÉLIORATION 1 : Dessiner l'ANCIENNE vue qui sort
|
|
2776
|
+
this.ctx.save();
|
|
2777
|
+
|
|
2778
|
+
// L'ancienne vue se déplace vers la gauche/droite
|
|
2779
|
+
const oldOffset = -this.width * eased * directionMultiplier;
|
|
2780
|
+
this.ctx.translate(oldOffset, 0);
|
|
2781
|
+
|
|
2782
|
+
// Légère transparence pour donner de la profondeur
|
|
2783
|
+
this.ctx.globalAlpha = 1 - (eased * 0.3);
|
|
2784
|
+
|
|
2785
|
+
// Dessiner les anciens composants
|
|
2786
|
+
for (let comp of oldComponents) {
|
|
2787
|
+
if (comp && comp.visible) {
|
|
2788
|
+
const isFixed = this.isFixedComponent(comp);
|
|
2789
|
+
|
|
2790
|
+
if (isFixed) {
|
|
2791
|
+
comp.draw(this.ctx);
|
|
2792
|
+
} else {
|
|
2793
|
+
this.ctx.save();
|
|
2794
|
+
this.ctx.translate(0, 0); // Pas de scroll pendant la transition
|
|
2795
|
+
comp.draw(this.ctx);
|
|
2796
|
+
this.ctx.restore();
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
}
|
|
2800
|
+
|
|
2801
|
+
this.ctx.restore();
|
|
2802
|
+
|
|
2803
|
+
// ✅ AMÉLIORATION 2 : Dessiner la NOUVELLE vue qui entre
|
|
2755
2804
|
this.ctx.save();
|
|
2756
2805
|
|
|
2757
|
-
//
|
|
2758
|
-
this.
|
|
2806
|
+
// La nouvelle vue arrive de la droite/gauche
|
|
2807
|
+
const newOffset = this.width * (1 - eased) * directionMultiplier;
|
|
2808
|
+
this.ctx.translate(newOffset, 0);
|
|
2759
2809
|
|
|
2760
|
-
// Dessiner
|
|
2810
|
+
// Dessiner les nouveaux composants
|
|
2761
2811
|
for (let comp of newComponents) {
|
|
2762
2812
|
if (comp && comp.visible) {
|
|
2763
2813
|
const isFixed = this.isFixedComponent(comp);
|
|
@@ -2765,9 +2815,8 @@ class CanvasFramework {
|
|
|
2765
2815
|
if (isFixed) {
|
|
2766
2816
|
comp.draw(this.ctx);
|
|
2767
2817
|
} else {
|
|
2768
|
-
// Pour les composants scrollables, ajouter le décalage
|
|
2769
2818
|
this.ctx.save();
|
|
2770
|
-
this.ctx.translate(0,
|
|
2819
|
+
this.ctx.translate(0, 0); // Pas de scroll pendant la transition
|
|
2771
2820
|
comp.draw(this.ctx);
|
|
2772
2821
|
this.ctx.restore();
|
|
2773
2822
|
}
|
|
@@ -2776,20 +2825,39 @@ class CanvasFramework {
|
|
|
2776
2825
|
|
|
2777
2826
|
this.ctx.restore();
|
|
2778
2827
|
}
|
|
2779
|
-
// Pour fade, dessiner la nouvelle vue avec alpha
|
|
2780
2828
|
else if (type === 'fade') {
|
|
2829
|
+
// Ancienne vue qui fade out
|
|
2781
2830
|
this.ctx.save();
|
|
2782
|
-
this.ctx.globalAlpha =
|
|
2831
|
+
this.ctx.globalAlpha = 1 - eased;
|
|
2832
|
+
|
|
2833
|
+
for (let comp of oldComponents) {
|
|
2834
|
+
if (comp && comp.visible) {
|
|
2835
|
+
const isFixed = this.isFixedComponent(comp);
|
|
2836
|
+
if (isFixed) {
|
|
2837
|
+
comp.draw(this.ctx);
|
|
2838
|
+
} else {
|
|
2839
|
+
this.ctx.save();
|
|
2840
|
+
this.ctx.translate(0, 0);
|
|
2841
|
+
comp.draw(this.ctx);
|
|
2842
|
+
this.ctx.restore();
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
this.ctx.restore();
|
|
2848
|
+
|
|
2849
|
+
// Nouvelle vue qui fade in
|
|
2850
|
+
this.ctx.save();
|
|
2851
|
+
this.ctx.globalAlpha = eased;
|
|
2783
2852
|
|
|
2784
2853
|
for (let comp of newComponents) {
|
|
2785
2854
|
if (comp && comp.visible) {
|
|
2786
2855
|
const isFixed = this.isFixedComponent(comp);
|
|
2787
|
-
|
|
2788
2856
|
if (isFixed) {
|
|
2789
2857
|
comp.draw(this.ctx);
|
|
2790
2858
|
} else {
|
|
2791
2859
|
this.ctx.save();
|
|
2792
|
-
this.ctx.translate(0,
|
|
2860
|
+
this.ctx.translate(0, 0);
|
|
2793
2861
|
comp.draw(this.ctx);
|
|
2794
2862
|
this.ctx.restore();
|
|
2795
2863
|
}
|
|
@@ -2798,7 +2866,6 @@ class CanvasFramework {
|
|
|
2798
2866
|
|
|
2799
2867
|
this.ctx.restore();
|
|
2800
2868
|
}
|
|
2801
|
-
// Pour 'none', dessiner normalement
|
|
2802
2869
|
else {
|
|
2803
2870
|
this.renderFull();
|
|
2804
2871
|
}
|
package/index.js
CHANGED