Skip to content

Commit 48a9628

Browse files
Swordsman-Inactionalvaromb
authored andcommitted
Fix issue #104 (#106)
* Fix issue 104 * Clear enableResetScrollToCoords after reset keyboard space
1 parent 3a15f4e commit 48a9628

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/KeyboardAwareMixin.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ const KeyboardAwareMixin = {
7676
)
7777
}
7878
if (!this.resetCoords) {
79-
this.defaultResetScrollToCoords = this.position
79+
if (!this.defaultResetScrollToCoords) {
80+
this.defaultResetScrollToCoords = this.position
81+
}
8082
}
8183
},
8284

@@ -85,11 +87,17 @@ const KeyboardAwareMixin = {
8587
this.setState({keyboardSpace})
8688
// Reset scroll position after keyboard dismissal
8789
if (this.props.enableResetScrollToCoords === false) {
90+
this.defaultResetScrollToCoords = null
8891
return
8992
} else if (this.resetCoords) {
9093
this.scrollToPosition(this.resetCoords.x, this.resetCoords.y, true)
9194
} else {
92-
this.scrollToPosition(this.defaultResetScrollToCoords.x, this.defaultResetScrollToCoords.y, true)
95+
if (this.defaultResetScrollToCoords) {
96+
this.scrollToPosition(this.defaultResetScrollToCoords.x, this.defaultResetScrollToCoords.y, true)
97+
this.defaultResetScrollToCoords = null
98+
} else {
99+
this.scrollToPosition(0, 0, true)
100+
}
93101
}
94102
},
95103

@@ -128,7 +136,7 @@ const KeyboardAwareMixin = {
128136

129137
position: {x: 0, y: 0},
130138

131-
defaultResetScrollToCoords: {x: 0, y: 0},
139+
defaultResetScrollToCoords: null, // format: {x: 0, y: 0}
132140

133141
handleOnScroll: function (e) {
134142
this.position = e.nativeEvent.contentOffset

0 commit comments

Comments
 (0)