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.
- package/components/Card.js +30 -86
- package/package.json +1 -1
package/components/Card.js
CHANGED
|
@@ -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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.
|
|
76
|
-
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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
|
-
|
|
238
|
-
|
|
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
|
-
|
|
339
|
-
|
|
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();
|