canvasframework 0.5.37 → 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 -86
  2. package/package.json +1 -1
@@ -40,49 +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
-
53
- // 🔴 AJOUTER CETTE MÉTHODE
54
- _isMobileApp() {
55
- if (typeof window === 'undefined') return false;
56
- return !!(window.Capacitor || window.cordova || window.__FORCE_MOBILE_MODE__);
57
- }
58
46
 
59
47
  /**
60
- * Ajoute un enfant
48
+ * Ajoute un enfant (position relative convertie en absolue)
61
49
  * @param {Component} child - Composant enfant
62
50
  * @returns {Component} L'enfant ajouté
63
51
  */
64
52
  add(child) {
65
53
  this.children.push(child);
66
54
 
67
- if (this._isMobileApp()) {
68
- // CAPACITOR : Convertir en positions absolues
69
- const relativeX = child.x;
70
- const relativeY = child.y;
71
-
72
- child.x = this.x + relativeX;
73
- child.y = this.y + relativeY;
74
-
75
- this.childPositions.set(child, {
76
- x: relativeX,
77
- y: relativeY
78
- });
79
- } else {
80
- // WEB : Garder les positions relatives
81
- this.childPositions.set(child, {
82
- x: child.x,
83
- y: child.y
84
- });
85
- }
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
+ });
86
65
 
87
66
  // Si autoLayout est activé, organiser automatiquement
88
67
  if (this.autoLayout) {
@@ -140,15 +119,9 @@ class Card extends Component {
140
119
  child.width = this.width - (this.padding * 2);
141
120
  }
142
121
 
143
- if (this._isMobileApp()) {
144
- // CAPACITOR : Positions absolues
145
- child.x = this.x + childX;
146
- child.y = this.y + currentY;
147
- } else {
148
- // WEB : Positions relatives
149
- child.x = childX;
150
- child.y = currentY;
151
- }
122
+ // Positionner l'enfant RELATIVEMENT à la Card
123
+ child.x = this.x + childX;
124
+ child.y = this.y + currentY;
152
125
 
153
126
  // Stocker la position relative
154
127
  this.childPositions.set(child, { x: childX, y: currentY });
@@ -179,15 +152,9 @@ class Card extends Component {
179
152
  child.height = this.height - (this.padding * 2);
180
153
  }
181
154
 
182
- if (this._isMobileApp()) {
183
- // CAPACITOR : Positions absolues
184
- child.x = this.x + currentX;
185
- child.y = this.y + childY;
186
- } else {
187
- // WEB : Positions relatives
188
- child.x = currentX;
189
- child.y = childY;
190
- }
155
+ // Positionner l'enfant RELATIVEMENT à la Card
156
+ child.x = this.x + currentX;
157
+ child.y = this.y + childY;
191
158
 
192
159
  // Stocker la position relative
193
160
  this.childPositions.set(child, { x: currentX, y: childY });
@@ -209,20 +176,15 @@ class Card extends Component {
209
176
  * @param {number} y - Nouvelle position Y
210
177
  */
211
178
  setPosition(x, y) {
212
- if (this._isMobileApp()) {
213
- // CAPACITOR : Déplacer les enfants avec la carte
214
- const deltaX = x - this.x;
215
- const deltaY = y - this.y;
216
-
217
- super.setPosition(x, y);
218
-
219
- for (let child of this.children) {
220
- child.x += deltaX;
221
- child.y += deltaY;
222
- }
223
- } else {
224
- // WEB : Les enfants sont en relatif, pas besoin de les déplacer
225
- 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;
226
188
  }
227
189
  }
228
190
 
@@ -234,13 +196,8 @@ class Card extends Component {
234
196
  */
235
197
  setChildPosition(child, relativeX, relativeY) {
236
198
  if (this.children.includes(child)) {
237
- if (this._isMobileApp()) {
238
- child.x = this.x + relativeX;
239
- child.y = this.y + relativeY;
240
- } else {
241
- child.x = relativeX;
242
- child.y = relativeY;
243
- }
199
+ child.x = this.x + relativeX;
200
+ child.y = this.y + relativeY;
244
201
  this.childPositions.set(child, { x: relativeX, y: relativeY });
245
202
  }
246
203
  }
@@ -335,21 +292,8 @@ class Card extends Component {
335
292
  }
336
293
 
337
294
  // Dessiner les enfants
338
- if (this._isMobileApp()) {
339
- // CAPACITOR : Dessiner directement (positions absolues)
340
- for (let child of this.children) {
341
- if (child.visible) child.draw(ctx);
342
- }
343
- } else {
344
- // WEB : Dessiner avec translate (positions relatives)
345
- ctx.save();
346
- ctx.translate(this.x, this.y);
347
-
348
- for (let child of this.children) {
349
- if (child.visible) child.draw(ctx);
350
- }
351
-
352
- ctx.restore();
295
+ for (let child of this.children) {
296
+ if (child.visible) child.draw(ctx);
353
297
  }
354
298
 
355
299
  ctx.restore();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvasframework",
3
- "version": "0.5.37",
3
+ "version": "0.5.38",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/beyons/CanvasFramework.git"