canvasframework 0.5.35 → 0.5.37
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 +13 -7
- package/package.json +1 -1
package/components/Card.js
CHANGED
|
@@ -44,11 +44,17 @@ class Card extends Component {
|
|
|
44
44
|
this.clickableChildren = true;
|
|
45
45
|
|
|
46
46
|
// 🔴 Détecter la plateforme
|
|
47
|
-
this.isCapacitor = typeof window !== 'undefined' && window.Capacitor;
|
|
47
|
+
//this.isCapacitor = typeof window !== 'undefined' && (window.Capacitor || window.cordova);
|
|
48
48
|
|
|
49
49
|
// Stocker les positions relatives des enfants
|
|
50
50
|
this.childPositions = new Map();
|
|
51
51
|
}
|
|
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
|
+
}
|
|
52
58
|
|
|
53
59
|
/**
|
|
54
60
|
* Ajoute un enfant
|
|
@@ -58,7 +64,7 @@ class Card extends Component {
|
|
|
58
64
|
add(child) {
|
|
59
65
|
this.children.push(child);
|
|
60
66
|
|
|
61
|
-
if (this.
|
|
67
|
+
if (this._isMobileApp()) {
|
|
62
68
|
// CAPACITOR : Convertir en positions absolues
|
|
63
69
|
const relativeX = child.x;
|
|
64
70
|
const relativeY = child.y;
|
|
@@ -134,7 +140,7 @@ class Card extends Component {
|
|
|
134
140
|
child.width = this.width - (this.padding * 2);
|
|
135
141
|
}
|
|
136
142
|
|
|
137
|
-
if (this.
|
|
143
|
+
if (this._isMobileApp()) {
|
|
138
144
|
// CAPACITOR : Positions absolues
|
|
139
145
|
child.x = this.x + childX;
|
|
140
146
|
child.y = this.y + currentY;
|
|
@@ -173,7 +179,7 @@ class Card extends Component {
|
|
|
173
179
|
child.height = this.height - (this.padding * 2);
|
|
174
180
|
}
|
|
175
181
|
|
|
176
|
-
if (this.
|
|
182
|
+
if (this._isMobileApp()) {
|
|
177
183
|
// CAPACITOR : Positions absolues
|
|
178
184
|
child.x = this.x + currentX;
|
|
179
185
|
child.y = this.y + childY;
|
|
@@ -203,7 +209,7 @@ class Card extends Component {
|
|
|
203
209
|
* @param {number} y - Nouvelle position Y
|
|
204
210
|
*/
|
|
205
211
|
setPosition(x, y) {
|
|
206
|
-
if (this.
|
|
212
|
+
if (this._isMobileApp()) {
|
|
207
213
|
// CAPACITOR : Déplacer les enfants avec la carte
|
|
208
214
|
const deltaX = x - this.x;
|
|
209
215
|
const deltaY = y - this.y;
|
|
@@ -228,7 +234,7 @@ class Card extends Component {
|
|
|
228
234
|
*/
|
|
229
235
|
setChildPosition(child, relativeX, relativeY) {
|
|
230
236
|
if (this.children.includes(child)) {
|
|
231
|
-
if (this.
|
|
237
|
+
if (this._isMobileApp()) {
|
|
232
238
|
child.x = this.x + relativeX;
|
|
233
239
|
child.y = this.y + relativeY;
|
|
234
240
|
} else {
|
|
@@ -329,7 +335,7 @@ class Card extends Component {
|
|
|
329
335
|
}
|
|
330
336
|
|
|
331
337
|
// Dessiner les enfants
|
|
332
|
-
if (this.
|
|
338
|
+
if (this._isMobileApp()) {
|
|
333
339
|
// CAPACITOR : Dessiner directement (positions absolues)
|
|
334
340
|
for (let child of this.children) {
|
|
335
341
|
if (child.visible) child.draw(ctx);
|