canvasframework 0.5.36 → 0.5.38

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.
Files changed (2) hide show
  1. package/components/Card.js +30 -80
  2. package/package.json +1 -1
@@ -40,43 +40,28 @@ class Card extends Component {
40
40
  this.elevation = options.elevation || 0;
41
41
  this.autoLayout = options.autoLayout !== undefined ? options.autoLayout : true;
42
42
 
43
- // 🔴 IMPORTANT : Activer la gestion des clics pour les enfants
44
- this.clickableChildren = true;
45
-
46
- // 🔴 Détecter la plateforme
47
- this.isCapacitor = typeof window !== 'undefined' && (window.Capacitor || window.cordova);
48
-
49
43
  // Stocker les positions relatives des enfants
50
44
  this.childPositions = new Map();
51
45
  }
52
46
 
53
47
  /**
54
- * Ajoute un enfant
48
+ * Ajoute un enfant (position relative convertie en absolue)
55
49
  * @param {Component} child - Composant enfant
56
50
  * @returns {Component} L'enfant ajouté
57
51
  */
58
52
  add(child) {
59
53
  this.children.push(child);
60
54
 
61
- if (this.isCapacitor) {
62
- // CAPACITOR : Convertir en positions absolues
63
- const relativeX = child.x;
64
- const relativeY = child.y;
65
-
66
- child.x = this.x + relativeX;
67
- child.y = this.y + relativeY;
68
-
69
- this.childPositions.set(child, {
70
- x: relativeX,
71
- y: relativeY
72
- });
73
- } else {
74
- // WEB : Garder les positions relatives
75
- this.childPositions.set(child, {
76
- x: child.x,
77
- y: child.y
78
- });
79
- }
55
+ // CONVERTIR les positions relatives en positions absolues
56
+ // Les x, y passés sont relatifs à la Card
57
+ child.x = this.x + child.x;
58
+ child.y = this.y + child.y;
59
+
60
+ // Stocker la position relative originale
61
+ this.childPositions.set(child, {
62
+ x: child.x - this.x,
63
+ y: child.y - this.y
64
+ });
80
65
 
81
66
  // Si autoLayout est activé, organiser automatiquement
82
67
  if (this.autoLayout) {
@@ -134,15 +119,9 @@ class Card extends Component {
134
119
  child.width = this.width - (this.padding * 2);
135
120
  }
136
121
 
137
- if (this.isCapacitor) {
138
- // CAPACITOR : Positions absolues
139
- child.x = this.x + childX;
140
- child.y = this.y + currentY;
141
- } else {
142
- // WEB : Positions relatives
143
- child.x = childX;
144
- child.y = currentY;
145
- }
122
+ // Positionner l'enfant RELATIVEMENT à la Card
123
+ child.x = this.x + childX;
124
+ child.y = this.y + currentY;
146
125
 
147
126
  // Stocker la position relative
148
127
  this.childPositions.set(child, { x: childX, y: currentY });
@@ -173,15 +152,9 @@ class Card extends Component {
173
152
  child.height = this.height - (this.padding * 2);
174
153
  }
175
154
 
176
- if (this.isCapacitor) {
177
- // CAPACITOR : Positions absolues
178
- child.x = this.x + currentX;
179
- child.y = this.y + childY;
180
- } else {
181
- // WEB : Positions relatives
182
- child.x = currentX;
183
- child.y = childY;
184
- }
155
+ // Positionner l'enfant RELATIVEMENT à la Card
156
+ child.x = this.x + currentX;
157
+ child.y = this.y + childY;
185
158
 
186
159
  // Stocker la position relative
187
160
  this.childPositions.set(child, { x: currentX, y: childY });
@@ -203,20 +176,15 @@ class Card extends Component {
203
176
  * @param {number} y - Nouvelle position Y
204
177
  */
205
178
  setPosition(x, y) {
206
- if (this.isCapacitor) {
207
- // CAPACITOR : Déplacer les enfants avec la carte
208
- const deltaX = x - this.x;
209
- const deltaY = y - this.y;
210
-
211
- super.setPosition(x, y);
212
-
213
- for (let child of this.children) {
214
- child.x += deltaX;
215
- child.y += deltaY;
216
- }
217
- } else {
218
- // WEB : Les enfants sont en relatif, pas besoin de les déplacer
219
- super.setPosition(x, y);
179
+ const deltaX = x - this.x;
180
+ const deltaY = y - this.y;
181
+
182
+ super.setPosition(x, y);
183
+
184
+ // Déplacer tous les enfants avec la carte
185
+ for (let child of this.children) {
186
+ child.x += deltaX;
187
+ child.y += deltaY;
220
188
  }
221
189
  }
222
190
 
@@ -228,13 +196,8 @@ class Card extends Component {
228
196
  */
229
197
  setChildPosition(child, relativeX, relativeY) {
230
198
  if (this.children.includes(child)) {
231
- if (this.isCapacitor) {
232
- child.x = this.x + relativeX;
233
- child.y = this.y + relativeY;
234
- } else {
235
- child.x = relativeX;
236
- child.y = relativeY;
237
- }
199
+ child.x = this.x + relativeX;
200
+ child.y = this.y + relativeY;
238
201
  this.childPositions.set(child, { x: relativeX, y: relativeY });
239
202
  }
240
203
  }
@@ -329,21 +292,8 @@ class Card extends Component {
329
292
  }
330
293
 
331
294
  // Dessiner les enfants
332
- if (this.isCapacitor) {
333
- // CAPACITOR : Dessiner directement (positions absolues)
334
- for (let child of this.children) {
335
- if (child.visible) child.draw(ctx);
336
- }
337
- } else {
338
- // WEB : Dessiner avec translate (positions relatives)
339
- ctx.save();
340
- ctx.translate(this.x, this.y);
341
-
342
- for (let child of this.children) {
343
- if (child.visible) child.draw(ctx);
344
- }
345
-
346
- ctx.restore();
295
+ for (let child of this.children) {
296
+ if (child.visible) child.draw(ctx);
347
297
  }
348
298
 
349
299
  ctx.restore();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvasframework",
3
- "version": "0.5.36",
3
+ "version": "0.5.38",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/beyons/CanvasFramework.git"