react-native-keyboard-controller 1.20.1 → 1.20.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.
@@ -0,0 +1,9 @@
1
+ package com.reactnativekeyboardcontroller.constants
2
+
3
+ import kotlin.math.floor
4
+
5
+ object UIThread {
6
+ const val MILLISECONDS_IN_SECOND = 1000.0
7
+ const val FPS = 60
8
+ val NEXT_FRAME = floor(MILLISECONDS_IN_SECOND / FPS).toLong()
9
+ }
@@ -14,6 +14,7 @@ import com.facebook.react.uimanager.ThemedReactContext
14
14
  import com.facebook.react.uimanager.UIManagerHelper
15
15
  import com.facebook.react.views.view.ReactViewGroup
16
16
  import com.reactnativekeyboardcontroller.constants.Keyboard
17
+ import com.reactnativekeyboardcontroller.constants.UIThread
17
18
  import com.reactnativekeyboardcontroller.events.KeyboardTransitionEvent
18
19
  import com.reactnativekeyboardcontroller.extensions.appearance
19
20
  import com.reactnativekeyboardcontroller.extensions.dispatchEvent
@@ -334,8 +335,8 @@ class KeyboardAnimationCallback(
334
335
 
335
336
  if (isKeyboardInteractive) {
336
337
  // in case of interactive keyboard we can not read keyboard frame straight away
337
- // (because we'll always read `0`), so we are posting runnable to the main thread
338
- view.post(runnable)
338
+ // (because we'll always read `0`), so we are posting runnable to the next frame on the main thread
339
+ view.postDelayed(runnable, UIThread.NEXT_FRAME)
339
340
  } else {
340
341
  runnable.run()
341
342
  }
@@ -41,7 +41,7 @@ private class BaseContainerView: UIInputView {
41
41
  }
42
42
 
43
43
  func setupContainerSpecifics() {
44
- // Override in subclasses
44
+ updateContentFrame(desiredHeight: calculateDesiredHeight())
45
45
  }
46
46
 
47
47
  func calculateDesiredHeight() -> CGFloat {
@@ -54,7 +54,7 @@ private class BaseContainerView: UIInputView {
54
54
 
55
55
  let desiredHeight = calculateDesiredHeight()
56
56
 
57
- if frame.height != desiredHeight {
57
+ if abs(frame.height - desiredHeight) > 0.001 {
58
58
  frame.size.height = desiredHeight
59
59
 
60
60
  updateContentFrame(desiredHeight: desiredHeight)
@@ -85,6 +85,7 @@ private class ModernContainerView: BaseContainerView {
85
85
 
86
86
  override func setupContainerSpecifics() {
87
87
  setupVisualEffect()
88
+ super.setupContainerSpecifics()
88
89
  }
89
90
 
90
91
  private func setupVisualEffect() {
@@ -128,6 +129,7 @@ private class ModernContainerView: BaseContainerView {
128
129
  private class LegacyContainerView: BaseContainerView {
129
130
  override func setupContainerSpecifics() {
130
131
  addSubview(contentView)
132
+ super.setupContainerSpecifics()
131
133
  }
132
134
 
133
135
  override func updateContentFrame(desiredHeight _: CGFloat) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-keyboard-controller",
3
- "version": "1.20.1",
3
+ "version": "1.20.2",
4
4
  "description": "Keyboard manager which works in identical way on both iOS and Android",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",