canvasframework 0.5.11 → 0.5.12

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.
@@ -2745,19 +2745,48 @@ class CanvasFramework {
2745
2745
  renderSimpleTransition() {
2746
2746
  const { progress, type, direction, oldComponents, newComponents } = this.transitionState;
2747
2747
 
2748
- // Calculer la position de décalage
2749
- const slideOffset = this.width * (1 - progress);
2748
+ // Easing pour une animation plus fluide
2749
+ const eased = this.easeInOutCubic(progress);
2750
+
2750
2751
  const directionMultiplier = direction === 'forward' ? 1 : -1;
2751
2752
 
2752
- // Pour l'animation slide, dessiner seulement la nouvelle vue à la bonne position
2753
2753
  if (type === 'slide') {
2754
- // Sauvegarder le contexte
2754
+ // AMÉLIORATION 1 : Dessiner l'ANCIENNE vue qui sort
2755
2755
  this.ctx.save();
2756
2756
 
2757
- // Appliquer la translation pour l'animation
2758
- this.ctx.translate(slideOffset * directionMultiplier, 0);
2757
+ // L'ancienne vue se déplace vers la gauche/droite
2758
+ const oldOffset = -this.width * eased * directionMultiplier;
2759
+ this.ctx.translate(oldOffset, 0);
2760
+
2761
+ // Légère transparence pour donner de la profondeur
2762
+ this.ctx.globalAlpha = 1 - (eased * 0.3);
2763
+
2764
+ // Dessiner les anciens composants
2765
+ for (let comp of oldComponents) {
2766
+ if (comp && comp.visible) {
2767
+ const isFixed = this.isFixedComponent(comp);
2768
+
2769
+ if (isFixed) {
2770
+ comp.draw(this.ctx);
2771
+ } else {
2772
+ this.ctx.save();
2773
+ this.ctx.translate(0, 0); // Pas de scroll pendant la transition
2774
+ comp.draw(this.ctx);
2775
+ this.ctx.restore();
2776
+ }
2777
+ }
2778
+ }
2779
+
2780
+ this.ctx.restore();
2781
+
2782
+ // ✅ AMÉLIORATION 2 : Dessiner la NOUVELLE vue qui entre
2783
+ this.ctx.save();
2759
2784
 
2760
- // Dessiner UNIQUEMENT les nouveaux composants
2785
+ // La nouvelle vue arrive de la droite/gauche
2786
+ const newOffset = this.width * (1 - eased) * directionMultiplier;
2787
+ this.ctx.translate(newOffset, 0);
2788
+
2789
+ // Dessiner les nouveaux composants
2761
2790
  for (let comp of newComponents) {
2762
2791
  if (comp && comp.visible) {
2763
2792
  const isFixed = this.isFixedComponent(comp);
@@ -2765,9 +2794,8 @@ class CanvasFramework {
2765
2794
  if (isFixed) {
2766
2795
  comp.draw(this.ctx);
2767
2796
  } else {
2768
- // Pour les composants scrollables, ajouter le décalage
2769
2797
  this.ctx.save();
2770
- this.ctx.translate(0, this.scrollOffset);
2798
+ this.ctx.translate(0, 0); // Pas de scroll pendant la transition
2771
2799
  comp.draw(this.ctx);
2772
2800
  this.ctx.restore();
2773
2801
  }
@@ -2776,20 +2804,39 @@ class CanvasFramework {
2776
2804
 
2777
2805
  this.ctx.restore();
2778
2806
  }
2779
- // Pour fade, dessiner la nouvelle vue avec alpha
2780
2807
  else if (type === 'fade') {
2808
+ // Ancienne vue qui fade out
2809
+ this.ctx.save();
2810
+ this.ctx.globalAlpha = 1 - eased;
2811
+
2812
+ for (let comp of oldComponents) {
2813
+ if (comp && comp.visible) {
2814
+ const isFixed = this.isFixedComponent(comp);
2815
+ if (isFixed) {
2816
+ comp.draw(this.ctx);
2817
+ } else {
2818
+ this.ctx.save();
2819
+ this.ctx.translate(0, 0);
2820
+ comp.draw(this.ctx);
2821
+ this.ctx.restore();
2822
+ }
2823
+ }
2824
+ }
2825
+
2826
+ this.ctx.restore();
2827
+
2828
+ // Nouvelle vue qui fade in
2781
2829
  this.ctx.save();
2782
- this.ctx.globalAlpha = progress;
2830
+ this.ctx.globalAlpha = eased;
2783
2831
 
2784
2832
  for (let comp of newComponents) {
2785
2833
  if (comp && comp.visible) {
2786
2834
  const isFixed = this.isFixedComponent(comp);
2787
-
2788
2835
  if (isFixed) {
2789
2836
  comp.draw(this.ctx);
2790
2837
  } else {
2791
2838
  this.ctx.save();
2792
- this.ctx.translate(0, this.scrollOffset);
2839
+ this.ctx.translate(0, 0);
2793
2840
  comp.draw(this.ctx);
2794
2841
  this.ctx.restore();
2795
2842
  }
@@ -2798,7 +2845,6 @@ class CanvasFramework {
2798
2845
 
2799
2846
  this.ctx.restore();
2800
2847
  }
2801
- // Pour 'none', dessiner normalement
2802
2848
  else {
2803
2849
  this.renderFull();
2804
2850
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvasframework",
3
- "version": "0.5.11",
3
+ "version": "0.5.12",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/beyons/CanvasFramework.git"