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.
- package/components/Card.js +30 -80
- package/package.json +1 -1
package/components/Card.js
CHANGED
|
@@ -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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.
|
|
70
|
-
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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
|
-
|
|
232
|
-
|
|
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
|
-
|
|
333
|
-
|
|
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();
|