react-native-gleam 1.0.3 → 1.0.4

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.
Files changed (2) hide show
  1. package/ios/GleamView.mm +27 -2
  2. package/package.json +1 -1
package/ios/GleamView.mm CHANGED
@@ -190,6 +190,28 @@ static void _unregisterView(GleamView *view) {
190
190
  }
191
191
  }
192
192
 
193
+ - (void)didMoveToWindow
194
+ {
195
+ [super didMoveToWindow];
196
+ if (!self.window) return;
197
+
198
+ // View (re)joined a window — resync visual state.
199
+ // Mirrors Android's onAttachedToWindow re-attachment path.
200
+ if (_loading) {
201
+ if (_shimmerLayer.superlayer != self.layer) {
202
+ [self.layer addSublayer:_shimmerLayer];
203
+ }
204
+ [self _registerClock];
205
+ } else if (!_isTransitioning) {
206
+ // _isTransitioning=YES means ticks are actively driving it to
207
+ // completion (we no longer bail on !self.window) — let it finish.
208
+ [self _setChildrenAlphaIfNeeded:1.0];
209
+ _shimmerLayer.opacity = 0.0;
210
+ [_shimmerLayer removeFromSuperlayer];
211
+ [self _unregisterClock];
212
+ }
213
+ }
214
+
193
215
  - (void)removeFromSuperview
194
216
  {
195
217
  [self _unregisterClock];
@@ -362,8 +384,10 @@ static void _unregisterView(GleamView *view) {
362
384
 
363
385
  - (void)_tickWithTime:(CFTimeInterval)now
364
386
  {
365
- if (!self.window) return;
366
-
387
+ // Transitions must always complete to avoid stuck visual state when the
388
+ // view is hidden (display:'none' → hidden=YES) or has no window.
389
+ // Cost is bounded (≤ transitionDuration) and the ops are cheap property sets.
390
+ // Shimmer animation is cosmetic and unbounded — skip when not visible.
367
391
  if (_isTransitioning) {
368
392
  _transitionElapsed += _displayLink.duration;
369
393
  CGFloat t = _transitionDuration > 0 ? fmin(_transitionElapsed / _transitionDuration, 1.0) : 1.0;
@@ -436,6 +460,7 @@ static void _unregisterView(GleamView *view) {
436
460
  [self _finishTransition];
437
461
  }
438
462
  } else if (_loading) {
463
+ if (!self.window) return;
439
464
  [self _updateGradientPositionWithTime:now];
440
465
  }
441
466
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gleam",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Native-powered shimmer loading effect for React Native",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",