canvasframework 0.5.62 → 0.5.63

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.
@@ -492,9 +492,10 @@ class CanvasFramework {
492
492
  }
493
493
 
494
494
  this.platform = this.detectPlatform();
495
- setTimeout(() => {
495
+ /*setTimeout(() => {
496
496
  this.initScrollWorker();
497
- }, 100);
497
+ }, 100);*/
498
+ Promise.resolve().then(() => this.initScrollWorker());
498
499
  // État actuel + préférence
499
500
  this.themeMode = options.themeMode || 'system'; // 'light', 'dark', 'system'
500
501
  this.userThemeOverride = null; // null = suit system, sinon 'light' ou 'dark'
@@ -2958,6 +2959,7 @@ class CanvasFramework {
2958
2959
 
2959
2960
  startRenderLoop() {
2960
2961
  let lastScrollOffset = this.scrollOffset;
2962
+ this._needsRender = true; // ← AJOUTER
2961
2963
 
2962
2964
  const render = () => {
2963
2965
  if (!this._splashFinished) {
@@ -3137,84 +3139,34 @@ class CanvasFramework {
3137
3139
  /**
3138
3140
  * Dessine l'effet d'overscroll (overlay gris)
3139
3141
  */
3140
- drawOverscrollEffect() {console.log('dessine');
3142
+ drawOverscrollEffect() {
3141
3143
  if (Math.abs(this.overscrollDistance) < 1) return;
3142
3144
 
3143
3145
  const ctx = this.ctx;
3144
- ctx.save();
3145
-
3146
- // Calculer l'opacité (max 0.4 pour Android)
3147
3146
  const maxOverscroll = 150;
3148
3147
  const opacity = Math.min(Math.abs(this.overscrollDistance) / maxOverscroll, 1) * 0.4;
3149
-
3150
- // Hauteur de l'overlay
3151
3148
  const overlayHeight = Math.min(Math.abs(this.overscrollDistance) * 1.2, 250);
3149
+ const isTop = this.overscrollDistance > 0;
3152
3150
 
3153
- let gradient;
3151
+ // Cache key basé sur les paramètres
3152
+ const cacheKey = `${isTop}-${opacity.toFixed(3)}-${overlayHeight.toFixed(0)}`;
3154
3153
 
3155
- // Overscroll en haut
3156
- if (this.overscrollDistance > 0) {
3157
- gradient = ctx.createLinearGradient(0, 0, 0, overlayHeight);
3158
- gradient.addColorStop(0, `rgba(100, 100, 100, ${opacity})`);
3159
- gradient.addColorStop(1, 'rgba(100, 100, 100, 0)');
3154
+ if (this._overscrollGradientCache?.key !== cacheKey) {
3155
+ const gradient = isTop
3156
+ ? ctx.createLinearGradient(0, 0, 0, overlayHeight)
3157
+ : ctx.createLinearGradient(0, this.height - overlayHeight, 0, this.height);
3160
3158
 
3161
- ctx.fillStyle = gradient;
3162
- ctx.fillRect(0, 0, this.width, overlayHeight);
3163
- }
3164
- // Overscroll en bas
3165
- else if (this.overscrollDistance < 0) {
3166
- gradient = ctx.createLinearGradient(0, this.height - overlayHeight, 0, this.height);
3167
- gradient.addColorStop(0, 'rgba(100, 100, 100, 0)');
3168
- gradient.addColorStop(1, `rgba(100, 100, 100, ${opacity})`);
3159
+ gradient.addColorStop(0, isTop ? `rgba(100,100,100,${opacity})` : 'rgba(100,100,100,0)');
3160
+ gradient.addColorStop(1, isTop ? 'rgba(100,100,100,0)' : `rgba(100,100,100,${opacity})`);
3169
3161
 
3170
- ctx.fillStyle = gradient;
3171
- ctx.fillRect(0, this.height - overlayHeight, this.width, overlayHeight);
3162
+ this._overscrollGradientCache = { key: cacheKey, gradient, overlayHeight, isTop };
3172
3163
  }
3173
3164
 
3165
+ ctx.save();
3166
+ ctx.fillStyle = this._overscrollGradientCache.gradient;
3167
+ ctx.fillRect(0, isTop ? 0 : this.height - overlayHeight, this.width, overlayHeight);
3174
3168
  ctx.restore();
3175
3169
  }
3176
-
3177
- /**
3178
- * Rendu normal (sans transition)
3179
- */
3180
- renderFull() {
3181
- this.ctx.save();
3182
-
3183
- // Séparer les composants fixes et scrollables
3184
- const scrollableComponents = [];
3185
- const fixedComponents = [];
3186
-
3187
- for (let comp of this.components) {
3188
- if (this.isFixedComponent(comp)) {
3189
- fixedComponents.push(comp);
3190
- } else {
3191
- scrollableComponents.push(comp);
3192
- }
3193
- }
3194
-
3195
- // Dessiner les composants scrollables
3196
- if (scrollableComponents.length > 0) {
3197
- this.ctx.save();
3198
- this.ctx.translate(0, this.scrollOffset);
3199
-
3200
- for (let comp of scrollableComponents) {
3201
- if (comp.visible) {
3202
- comp.draw(this.ctx);
3203
- }
3204
- }
3205
-
3206
- this.ctx.restore();
3207
- }
3208
-
3209
- // Dessiner les composants fixes
3210
- for (let comp of fixedComponents) {
3211
- if (comp.visible) {
3212
- comp.draw(this.ctx);
3213
- }
3214
- }
3215
-
3216
- this.ctx.restore();
3217
- }
3218
3170
 
3219
3171
  /**
3220
3172
  * Mettre à jour la progression de la transition
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvasframework",
3
- "version": "0.5.62",
3
+ "version": "0.5.63",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/beyons/CanvasFramework.git"