@sbaiahmed1/react-native-blur 4.5.5-beta.1 → 4.5.5-beta.2

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.
@@ -35,6 +35,8 @@ class ReactNativeProgressiveBlurView : FrameLayout {
35
35
  private var currentStartOffset = 0.0f
36
36
  private var hasExplicitBackground: Boolean = false
37
37
  private var isBlurInitialized: Boolean = false
38
+ private var initRunnable: Runnable? = null
39
+ private var swapRootRunnable: Runnable? = null
38
40
 
39
41
  companion object {
40
42
  private const val TAG = "ReactNativeProgressiveBlur"
@@ -102,9 +104,12 @@ class ReactNativeProgressiveBlurView : FrameLayout {
102
104
  super.onAttachedToWindow()
103
105
 
104
106
  if (!isBlurInitialized) {
105
- post {
107
+ val runnable = Runnable {
108
+ initRunnable = null
106
109
  initializeBlurChild()
107
110
  }
111
+ initRunnable = runnable
112
+ post(runnable)
108
113
  }
109
114
  }
110
115
 
@@ -132,9 +137,12 @@ class ReactNativeProgressiveBlurView : FrameLayout {
132
137
  }
133
138
 
134
139
  // Swap blur root after BlurView is attached (deferred to let it attach first)
135
- blurView?.post {
140
+ val swapRunnable = Runnable {
141
+ swapRootRunnable = null
136
142
  swapBlurRootToScreenAncestor()
137
143
  }
144
+ swapRootRunnable = swapRunnable
145
+ blurView?.post(swapRunnable)
138
146
 
139
147
  isBlurInitialized = true
140
148
  logDebug("Initialized progressive blur with blur + gradient approach")
@@ -365,7 +373,12 @@ class ReactNativeProgressiveBlurView : FrameLayout {
365
373
  fun cleanup() {
366
374
  hasExplicitBackground = false
367
375
  isBlurInitialized = false
368
- removeCallbacks(null)
376
+ initRunnable?.let { removeCallbacks(it) }
377
+ initRunnable = null
378
+ swapRootRunnable?.let { runnable ->
379
+ blurView?.removeCallbacks(runnable)
380
+ }
381
+ swapRootRunnable = null
369
382
  logDebug("View cleaned up")
370
383
  }
371
384
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sbaiahmed1/react-native-blur",
3
- "version": "4.5.5-beta.1",
3
+ "version": "4.5.5-beta.2",
4
4
  "description": "React native modern blur view",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",