Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flash scroll indicators #530

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ interface KeyboardAwareProps {

interface KeyboardAwareScrollViewProps
extends KeyboardAwareProps,
ScrollViewProps {}
ScrollViewProps { }
interface KeyboardAwareFlatListProps<ItemT>
extends KeyboardAwareProps,
FlatListProps<ItemT> {}
FlatListProps<ItemT> { }
interface KeyboardAwareSectionListProps<ItemT>
extends KeyboardAwareProps,
SectionListProps<ItemT> {}
SectionListProps<ItemT> { }

interface KeyboardAwareState {
keyboardSpace: number
Expand All @@ -167,18 +167,19 @@ declare class ScrollableComponent<P, S> extends React.Component<P, S> {
extraHeight?: number,
keyboardOpeningTime?: number
) => void
flashScrollIndicators: () => void
}

export class KeyboardAwareMixin {}
export class KeyboardAwareMixin { }
export class KeyboardAwareScrollView extends ScrollableComponent<
KeyboardAwareScrollViewProps,
KeyboardAwareState
> {}
> { }
export class KeyboardAwareFlatList extends ScrollableComponent<
KeyboardAwareFlatListProps<any>,
KeyboardAwareState
> {}
> { }
export class KeyboardAwareSectionList extends ScrollableComponent<
KeyboardAwareSectionListProps<any>,
KeyboardAwareState
> {}
> { }
16 changes: 13 additions & 3 deletions lib/KeyboardAwareHOC.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,16 @@ function KeyboardAwareHOC(
this.scrollToPosition(0, this.position.y + extraHeight, true)
}

flashScrollIndicators = () => {
const responder = this.getScrollResponder()
if (!responder) {
return
}
if (responder.flashScrollIndicators) {
responder.flashScrollIndicators()
}
}

/**
* @param keyboardOpeningTime: takes a different keyboardOpeningTime in consideration.
* @param extraHeight: takes an extra height in consideration.
Expand Down Expand Up @@ -389,7 +399,7 @@ function KeyboardAwareHOC(
keyboardSpace -= _KAM_DEFAULT_TAB_BAR_HEIGHT
}
this.setState({ keyboardSpace })
const currentlyFocusedField = TextInput.State.currentlyFocusedInput ? findNodeHandle(TextInput.State.currentlyFocusedInput()) : TextInput.State.currentlyFocusedField()
const currentlyFocusedField = TextInput.State.currentlyFocusedInput ? findNodeHandle(TextInput.State.currentlyFocusedInput()) : TextInput.State.currentlyFocusedField()
const responder = this.getScrollResponder()
if (!currentlyFocusedField || !responder) {
return
Expand Down Expand Up @@ -434,7 +444,7 @@ function KeyboardAwareHOC(
) {
this.scrollForExtraHeightOnAndroid(
totalExtraHeight -
(keyboardPosition - textInputBottomPosition)
(keyboardPosition - textInputBottomPosition)
)
}
}
Expand Down Expand Up @@ -512,7 +522,7 @@ function KeyboardAwareHOC(
}

update = () => {
const currentlyFocusedField = TextInput.State.currentlyFocusedInput ? findNodeHandle(TextInput.State.currentlyFocusedInput()) : TextInput.State.currentlyFocusedField()
const currentlyFocusedField = TextInput.State.currentlyFocusedInput ? findNodeHandle(TextInput.State.currentlyFocusedInput()) : TextInput.State.currentlyFocusedField()
const responder = this.getScrollResponder()

if (!currentlyFocusedField || !responder) {
Expand Down
1 change: 1 addition & 0 deletions lib/KeyboardAwareInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export interface KeyboardAwareInterface {
extraHeight: number,
keyboardOpeningTime: number
) => void
flashScrollIndicators: () => void
}