canvasframework 0.5.21 → 0.5.23
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 +88 -85
- package/index.js +1 -1
- package/package.json +2 -9
package/components/Card.js
CHANGED
|
@@ -55,93 +55,96 @@ class Card extends Component {
|
|
|
55
55
|
* Dessine la carte et ses enfants
|
|
56
56
|
* @param {CanvasRenderingContext2D} ctx - Contexte de dessin
|
|
57
57
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
ctx.restore();
|
|
104
|
-
}
|
|
58
|
+
/**
|
|
59
|
+
* Dessine la carte et ses enfants
|
|
60
|
+
* @param {CanvasRenderingContext2D} ctx - Contexte de dessin
|
|
61
|
+
*/
|
|
62
|
+
draw(ctx) {
|
|
63
|
+
ctx.save();
|
|
64
|
+
|
|
65
|
+
// Ombre
|
|
66
|
+
if (this.elevation > 0) {
|
|
67
|
+
ctx.shadowColor = 'rgba(0, 0, 0, 0.15)';
|
|
68
|
+
ctx.shadowBlur = this.elevation * 3;
|
|
69
|
+
ctx.shadowOffsetY = this.elevation;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Background
|
|
73
|
+
ctx.fillStyle = this.bgColor;
|
|
74
|
+
ctx.beginPath();
|
|
75
|
+
this.roundRect(ctx, this.x, this.y, this.width, this.height, this.borderRadius);
|
|
76
|
+
ctx.fill();
|
|
77
|
+
|
|
78
|
+
ctx.shadowColor = 'transparent';
|
|
79
|
+
|
|
80
|
+
// Clipping pour empêcher le contenu de déborder
|
|
81
|
+
if (this.clipContent) {
|
|
82
|
+
ctx.beginPath();
|
|
83
|
+
this.roundRect(ctx, this.x, this.y, this.width, this.height, this.borderRadius);
|
|
84
|
+
ctx.clip();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Children - dessinés relativement à la Card
|
|
88
|
+
for (let child of this.children) {
|
|
89
|
+
if (child.visible) {
|
|
90
|
+
// *** FIX : Utiliser ctx.translate au lieu de modifier child.x/y ***
|
|
91
|
+
ctx.save();
|
|
92
|
+
ctx.translate(this.x + this.padding, this.y + this.padding);
|
|
93
|
+
|
|
94
|
+
// Dessiner l'enfant (ses coordonnées sont déjà relatives)
|
|
95
|
+
child.draw(ctx);
|
|
96
|
+
|
|
97
|
+
ctx.restore();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
ctx.restore();
|
|
102
|
+
}
|
|
105
103
|
|
|
106
104
|
/**
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
105
|
+
* Vérifie les clics sur les enfants
|
|
106
|
+
* @param {number} x - Coordonnée X
|
|
107
|
+
* @param {number} y - Coordonnée Y
|
|
108
|
+
* @returns {boolean} True si un enfant a été cliqué
|
|
109
|
+
* @private
|
|
110
|
+
*/
|
|
111
|
+
checkChildClick(x, y) {
|
|
112
|
+
// Ajuster y avec le scrollOffset
|
|
113
|
+
const adjustedY = y - (this.framework.scrollOffset || 0);
|
|
114
|
+
|
|
115
|
+
// Calculer les coordonnées de base de la Card
|
|
116
|
+
const baseX = this.x + this.padding;
|
|
117
|
+
const baseY = this.y + this.padding;
|
|
118
|
+
|
|
119
|
+
// Vérifier chaque enfant (du dernier au premier pour respecter z-index)
|
|
120
|
+
for (let i = this.children.length - 1; i >= 0; i--) {
|
|
121
|
+
const child = this.children[i];
|
|
122
|
+
|
|
123
|
+
if (!child.visible) continue;
|
|
124
|
+
|
|
125
|
+
// Coordonnées absolues de l'enfant
|
|
126
|
+
const childAbsX = baseX + child.x;
|
|
127
|
+
const childAbsY = baseY + child.y;
|
|
128
|
+
|
|
129
|
+
// Vérifier si le clic est dans l'enfant
|
|
130
|
+
if (adjustedY >= childAbsY &&
|
|
131
|
+
adjustedY <= childAbsY + child.height &&
|
|
132
|
+
x >= childAbsX &&
|
|
133
|
+
x <= childAbsX + child.width) {
|
|
134
|
+
|
|
135
|
+
// Déclencher onClick ou onPress
|
|
136
|
+
if (child.onClick) {
|
|
137
|
+
child.onClick();
|
|
138
|
+
return true;
|
|
139
|
+
} else if (child.onPress) {
|
|
140
|
+
child.onPress(x, adjustedY);
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
145
148
|
|
|
146
149
|
/**
|
|
147
150
|
* Dessine un rectangle avec coins arrondis
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "canvasframework",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.23",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/beyons/CanvasFramework.git"
|
|
@@ -28,12 +28,5 @@
|
|
|
28
28
|
"cupertino",
|
|
29
29
|
"mobile"
|
|
30
30
|
],
|
|
31
|
-
"license": "MIT"
|
|
32
|
-
"dependencies": {
|
|
33
|
-
"@babel/core": "^7.29.0",
|
|
34
|
-
"@babel/preset-env": "^7.29.0",
|
|
35
|
-
"babel-loader": "^10.0.0",
|
|
36
|
-
"webpack": "^5.105.0",
|
|
37
|
-
"webpack-cli": "^6.0.1"
|
|
38
|
-
}
|
|
31
|
+
"license": "MIT"
|
|
39
32
|
}
|