canvasframework 0.5.21 → 0.5.23

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.
@@ -55,93 +55,96 @@ class Card extends Component {
55
55
  * Dessine la carte et ses enfants
56
56
  * @param {CanvasRenderingContext2D} ctx - Contexte de dessin
57
57
  */
58
- draw(ctx) {
59
- ctx.save();
60
-
61
- // Ombre
62
- if (this.elevation > 0) {
63
- ctx.shadowColor = 'rgba(0, 0, 0, 0.15)';
64
- ctx.shadowBlur = this.elevation * 3;
65
- ctx.shadowOffsetY = this.elevation;
66
- }
67
-
68
- // Background
69
- ctx.fillStyle = this.bgColor;
70
- ctx.beginPath();
71
- this.roundRect(ctx, this.x, this.y, this.width, this.height, this.borderRadius);
72
- ctx.fill();
73
-
74
- ctx.shadowColor = 'transparent';
75
-
76
- // Clipping pour empêcher le contenu de déborder
77
- if (this.clipContent) {
78
- ctx.beginPath();
79
- this.roundRect(ctx, this.x, this.y, this.width, this.height, this.borderRadius);
80
- ctx.clip();
81
- }
82
-
83
- // Children - dessinés relativement à la Card
84
- for (let child of this.children) {
85
- if (child.visible) {
86
- // Sauvegarder les coordonnées originales
87
- const originalX = child.x;
88
- const originalY = child.y;
89
-
90
- // Ajuster les coordonnées pour être relatives à la Card
91
- child.x = this.x + this.padding + originalX;
92
- child.y = this.y + this.padding + originalY;
93
-
94
- // Dessiner l'enfant
95
- child.draw(ctx);
96
-
97
- // Restaurer les coordonnées originales
98
- child.x = originalX;
99
- child.y = originalY;
100
- }
101
- }
102
-
103
- ctx.restore();
104
- }
58
+ /**
59
+ * Dessine la carte et ses enfants
60
+ * @param {CanvasRenderingContext2D} ctx - Contexte de dessin
61
+ */
62
+ draw(ctx) {
63
+ ctx.save();
64
+
65
+ // Ombre
66
+ if (this.elevation > 0) {
67
+ ctx.shadowColor = 'rgba(0, 0, 0, 0.15)';
68
+ ctx.shadowBlur = this.elevation * 3;
69
+ ctx.shadowOffsetY = this.elevation;
70
+ }
71
+
72
+ // Background
73
+ ctx.fillStyle = this.bgColor;
74
+ ctx.beginPath();
75
+ this.roundRect(ctx, this.x, this.y, this.width, this.height, this.borderRadius);
76
+ ctx.fill();
77
+
78
+ ctx.shadowColor = 'transparent';
79
+
80
+ // Clipping pour empêcher le contenu de déborder
81
+ if (this.clipContent) {
82
+ ctx.beginPath();
83
+ this.roundRect(ctx, this.x, this.y, this.width, this.height, this.borderRadius);
84
+ ctx.clip();
85
+ }
86
+
87
+ // Children - dessinés relativement à la Card
88
+ for (let child of this.children) {
89
+ if (child.visible) {
90
+ // *** FIX : Utiliser ctx.translate au lieu de modifier child.x/y ***
91
+ ctx.save();
92
+ ctx.translate(this.x + this.padding, this.y + this.padding);
93
+
94
+ // Dessiner l'enfant (ses coordonnées sont déjà relatives)
95
+ child.draw(ctx);
96
+
97
+ ctx.restore();
98
+ }
99
+ }
100
+
101
+ ctx.restore();
102
+ }
105
103
 
106
104
  /**
107
- * Vérifie les clics sur les enfants
108
- * @param {number} x - Coordonnée X
109
- * @param {number} y - Coordonnée Y
110
- * @returns {boolean} True si un enfant a été cliqué
111
- * @private
112
- */
113
- checkChildClick(x, y) {
114
- // Ajuster y avec le scrollOffset
115
- const adjustedY = y - this.framework.scrollOffset;
116
-
117
- // Vérifier chaque enfant
118
- for (let i = this.children.length - 1; i >= 0; i--) {
119
- const child = this.children[i];
120
-
121
- // Calculer les coordonnées absolues de l'enfant
122
- const childX = this.x + this.padding + child.x;
123
- const childY = this.y + this.padding + child.y;
124
-
125
- // Vérifier si le clic est dans l'enfant
126
- if (child.visible &&
127
- adjustedY >= childY &&
128
- adjustedY <= childY + child.height &&
129
- x >= childX &&
130
- x <= childX + child.width) {
131
-
132
- // Si l'enfant a un onClick ou onPress, le déclencher
133
- if (child.onClick) {
134
- child.onClick();
135
- return true;
136
- } else if (child.onPress) {
137
- child.onPress(x, adjustedY);
138
- return true;
139
- }
140
- }
141
- }
142
-
143
- return false;
144
- }
105
+ * Vérifie les clics sur les enfants
106
+ * @param {number} x - Coordonnée X
107
+ * @param {number} y - Coordonnée Y
108
+ * @returns {boolean} True si un enfant a été cliqué
109
+ * @private
110
+ */
111
+ checkChildClick(x, y) {
112
+ // Ajuster y avec le scrollOffset
113
+ const adjustedY = y - (this.framework.scrollOffset || 0);
114
+
115
+ // Calculer les coordonnées de base de la Card
116
+ const baseX = this.x + this.padding;
117
+ const baseY = this.y + this.padding;
118
+
119
+ // Vérifier chaque enfant (du dernier au premier pour respecter z-index)
120
+ for (let i = this.children.length - 1; i >= 0; i--) {
121
+ const child = this.children[i];
122
+
123
+ if (!child.visible) continue;
124
+
125
+ // Coordonnées absolues de l'enfant
126
+ const childAbsX = baseX + child.x;
127
+ const childAbsY = baseY + child.y;
128
+
129
+ // Vérifier si le clic est dans l'enfant
130
+ if (adjustedY >= childAbsY &&
131
+ adjustedY <= childAbsY + child.height &&
132
+ x >= childAbsX &&
133
+ x <= childAbsX + child.width) {
134
+
135
+ // Déclencher onClick ou onPress
136
+ if (child.onClick) {
137
+ child.onClick();
138
+ return true;
139
+ } else if (child.onPress) {
140
+ child.onPress(x, adjustedY);
141
+ return true;
142
+ }
143
+ }
144
+ }
145
+
146
+ return false;
147
+ }
145
148
 
146
149
  /**
147
150
  * Dessine un rectangle avec coins arrondis
package/index.js CHANGED
@@ -116,4 +116,4 @@ export { default as FeatureFlags } from './manager/FeatureFlags.js';
116
116
 
117
117
  // Version du framework
118
118
 
119
- export const VERSION = '0.5.17';
119
+ export const VERSION = '0.5.22';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvasframework",
3
- "version": "0.5.21",
3
+ "version": "0.5.23",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/beyons/CanvasFramework.git"
@@ -28,12 +28,5 @@
28
28
  "cupertino",
29
29
  "mobile"
30
30
  ],
31
- "license": "MIT",
32
- "dependencies": {
33
- "@babel/core": "^7.29.0",
34
- "@babel/preset-env": "^7.29.0",
35
- "babel-loader": "^10.0.0",
36
- "webpack": "^5.105.0",
37
- "webpack-cli": "^6.0.1"
38
- }
31
+ "license": "MIT"
39
32
  }