canvasframework 0.5.44 → 0.5.45

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.
@@ -34,6 +34,18 @@ class Accordion extends Component {
34
34
 
35
35
  this.calculateContentHeight();
36
36
  this.height = this.headerHeight + (this.expanded ? this.contentHeight : 0);
37
+
38
+
39
+ this.onClick = () => {
40
+ if (this.animating) return;
41
+
42
+ // Ripple centré Material
43
+ if (this.platform === 'material') {
44
+ this.addRipple();
45
+ }
46
+
47
+ this.toggle();
48
+ };
37
49
 
38
50
  }
39
51
 
@@ -95,58 +107,34 @@ class Accordion extends Component {
95
107
 
96
108
  animate();
97
109
  }
98
-
99
- addRipple(localX, localY) {
100
-
101
- if (this.platform !== 'material') return;
102
-
103
- this.ripples.push({
104
- x: localX,
105
- y: localY,
110
+ addRipple() {
111
+ const ripple = {
112
+ x: this.width / 2,
113
+ y: this.headerHeight / 2,
106
114
  radius: 0,
107
- opacity: 0.25,
108
- maxRadius: Math.max(this.width, this.headerHeight)
109
- });
115
+ maxRadius: Math.max(this.width, this.headerHeight) * 1.5,
116
+ opacity: 0.3
117
+ };
118
+ this.ripples.push(ripple);
119
+ this.animateRipples();
120
+ }
110
121
 
122
+ animateRipples() {
111
123
  const animate = () => {
112
-
113
124
  let active = false;
114
-
115
- this.ripples.forEach(r => {
116
-
117
- if (r.radius < r.maxRadius) {
118
-
119
- r.radius += r.maxRadius / 12;
120
- r.opacity *= 0.9;
125
+ for (let ripple of this.ripples) {
126
+ if (ripple.radius < ripple.maxRadius) {
127
+ ripple.radius += ripple.maxRadius / 15;
128
+ ripple.opacity -= 0.03;
121
129
  active = true;
122
-
123
130
  }
124
-
125
- });
126
-
127
- this.ripples = this.ripples.filter(r => r.opacity > 0.02);
128
-
131
+ }
132
+ this.ripples = this.ripples.filter(r => r.opacity > 0);
129
133
  if (active) requestAnimationFrame(animate);
130
-
131
134
  };
132
-
133
135
  animate();
134
136
  }
135
137
 
136
- handleClick(x,y){
137
-
138
- const localX = x - this.x;
139
- const localY = y - this.y;
140
-
141
- if(localY <= this.headerHeight){
142
-
143
- this.addRipple(localX, localY);
144
- this.toggle();
145
-
146
- }
147
-
148
- }
149
-
150
138
  draw(ctx){
151
139
 
152
140
  ctx.save();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvasframework",
3
- "version": "0.5.44",
3
+ "version": "0.5.45",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/beyons/CanvasFramework.git"