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

Hint - fix target frame update #1478

Merged
merged 2 commits into from
Aug 22, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/components/hint/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ export interface HintProps {
* Callback for Hint press
*/
onPress?: () => void;
/**
* Callback for the background press
*/
/**
* Callback for the background press
*/
onBackgroundPress?: (event: GestureResponderEvent) => void;
/**
* The hint container width
Expand Down Expand Up @@ -217,15 +217,13 @@ class Hint extends Component<HintProps, HintState> {
if (!_.isEqual(this.state.targetLayout, layout)) {
this.setState({targetLayout: layout});
}

if (!this.state.targetLayoutInWindow) {
setTimeout(() => {
this.targetRef?.measureInWindow((x: number, y: number, width: number, height: number) => {
const targetLayoutInWindow = {x, y, width, height};
this.setState({targetLayoutInWindow});
});

setTimeout(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's make sense to re-measure only if the onBackgroundPress prop has been sent, cause otherwise it's not necessary

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

this.targetRef?.measureInWindow((x: number, y: number, width: number, height: number) => {
const targetLayoutInWindow = {x, y, width, height};
this.setState({targetLayoutInWindow});
});
}
});
};

getAccessibilityInfo() {
Expand Down