react-native-keyboard-controller 1.21.0-beta.0 → 1.21.0-beta.1

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.
@@ -49,6 +49,8 @@ extension KeyboardMovementObserver {
49
49
 
50
50
  prevKeyboardPosition = position
51
51
 
52
+ keyboardDidTask?.cancel()
53
+
52
54
  onEvent(
53
55
  "onKeyboardMoveInteractive",
54
56
  position as NSNumber,
@@ -7,7 +7,7 @@
7
7
 
8
8
  extension KeyboardMovementObserver {
9
9
  @objc func keyboardWillAppear(_ notification: Notification) {
10
- guard !KeyboardEventsIgnorer.shared.shouldIgnore, !UIResponder.isKeyboardPreloading else { return }
10
+ guard !UIResponder.isKeyboardPreloading else { return }
11
11
 
12
12
  let (duration, frame) = notification.keyboardMetaData()
13
13
  if let keyboardFrame = frame {
@@ -15,6 +15,12 @@ extension KeyboardMovementObserver {
15
15
  let keyboardHeight = keyboardFrame.cgRectValue.size.height
16
16
  self.keyboardHeight = keyboardHeight
17
17
  self.notification = notification
18
+
19
+ guard !KeyboardEventsIgnorer.shared.shouldIgnore else {
20
+ KeyboardEventsIgnorer.shared.shouldIgnoreKeyboardEvents = false
21
+ return
22
+ }
23
+
18
24
  self.duration = duration
19
25
 
20
26
  onRequestAnimation()
@@ -23,6 +29,7 @@ extension KeyboardMovementObserver {
23
29
 
24
30
  setupKeyboardWatcher()
25
31
  initializeAnimation(fromValue: prevKeyboardPosition, toValue: self.keyboardHeight)
32
+ scheduleDidEvent(height: self.keyboardHeight, duration: animation?.duration ?? CGFloat(duration) / 1000)
26
33
  }
27
34
  }
28
35
 
@@ -44,6 +51,7 @@ extension KeyboardMovementObserver {
44
51
  setupKeyboardWatcher()
45
52
  removeKVObserver()
46
53
  initializeAnimation(fromValue: prevKeyboardPosition, toValue: 0)
54
+ scheduleDidEvent(height: 0, duration: animation?.duration ?? CGFloat(duration) / 1000)
47
55
  }
48
56
 
49
57
  @objc func keyboardDidAppear(_ notification: Notification) {
@@ -55,12 +63,7 @@ extension KeyboardMovementObserver {
55
63
  tag = UIResponder.current.reactViewTag
56
64
  self.keyboardHeight = keyboardHeight
57
65
 
58
- guard !KeyboardEventsIgnorer.shared.shouldIgnore else {
59
- KeyboardEventsIgnorer.shared.shouldIgnoreKeyboardEvents = false
60
- return
61
- }
62
-
63
- let height = self.keyboardHeight - KeyboardAreaExtender.shared.offset
66
+ let height = self.keyboardHeight
64
67
  // always limit progress to the maximum possible value
65
68
  let progress = min(height / self.keyboardHeight, 1.0)
66
69
 
@@ -90,4 +93,24 @@ extension KeyboardMovementObserver {
90
93
  removeKeyboardWatcher()
91
94
  animation = nil
92
95
  }
96
+
97
+ @objc func scheduleDidEvent(height: CGFloat, duration: CGFloat) {
98
+ keyboardDidTask?.cancel()
99
+
100
+ guard let notification = notification else {
101
+ return
102
+ }
103
+
104
+ let task = DispatchWorkItem { [weak self] in
105
+ guard let self = self else { return }
106
+ if height > 0 {
107
+ self.keyboardDidAppear(notification)
108
+ } else {
109
+ self.keyboardDidDisappear(notification)
110
+ }
111
+ }
112
+
113
+ keyboardDidTask = task
114
+ DispatchQueue.main.asyncAfter(deadline: .now() + duration, execute: task)
115
+ }
93
116
  }
@@ -19,30 +19,7 @@ public class KeyboardMovementObserver: NSObject {
19
19
  var onCancelAnimation: () -> Void
20
20
  // progress tracker
21
21
  @objc public var keyboardTrackingView = KeyboardTrackingView()
22
- var animation: KeyboardAnimation? {
23
- didSet {
24
- keyboardDidTask?.cancel()
25
-
26
- guard let animation = animation, let notification = notification else {
27
- return
28
- }
29
-
30
- let toValue = animation.toValue
31
- let duration = animation.duration
32
-
33
- let task = DispatchWorkItem { [weak self] in
34
- guard let self = self else { return }
35
- if toValue > 0 {
36
- self.keyboardDidAppear(notification)
37
- } else {
38
- self.keyboardDidDisappear(notification)
39
- }
40
- }
41
-
42
- keyboardDidTask = task
43
- DispatchQueue.main.asyncAfter(deadline: .now() + duration, execute: task)
44
- }
45
- }
22
+ var animation: KeyboardAnimation?
46
23
 
47
24
  var prevKeyboardPosition = 0.0
48
25
  var displayLink: CADisplayLink!
@@ -55,30 +32,7 @@ public class KeyboardMovementObserver: NSObject {
55
32
  set { _keyboardHeight = newValue }
56
33
  }
57
34
 
58
- var duration = 0 {
59
- didSet {
60
- keyboardDidTask?.cancel()
61
-
62
- guard let notification = notification,
63
- let height = notification.keyboardMetaData().1?.cgRectValue.size.height, duration == 0
64
- else {
65
- return
66
- }
67
-
68
- let task = DispatchWorkItem { [weak self] in
69
- guard let self = self else { return }
70
- if height > 0 {
71
- self.keyboardDidAppear(notification)
72
- } else {
73
- self.keyboardDidDisappear(notification)
74
- }
75
- }
76
-
77
- keyboardDidTask = task
78
- DispatchQueue.main.asyncAfter(deadline: .now() + UIUtils.nextFrame, execute: task)
79
- }
80
- }
81
-
35
+ var duration = 0
82
36
  var tag: NSNumber = -1
83
37
  // manual did events
84
38
  var notification: Notification?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-keyboard-controller",
3
- "version": "1.21.0-beta.0",
3
+ "version": "1.21.0-beta.1",
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",
@@ -187,6 +187,5 @@
187
187
  "KeyboardExtender": "KeyboardExtender"
188
188
  }
189
189
  }
190
- },
191
- "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
190
+ }
192
191
  }