From 3eedfa9600f15dcea141075d22bda5ca35c24776 Mon Sep 17 00:00:00 2001 From: Benjamin Adzovic Novak Date: Tue, 7 Apr 2020 18:15:22 +0100 Subject: [PATCH 1/2] Add verticalOffset function support Specifically in react native navigation, the vertical offset is wrong on android (#106). This commit allows passing in an async function that can be executed at runtime to decide vertical offset based on the specific devices statusbar and topbar height (in react native navigations case, using await Navigation.constants() ) --- src/hocs/copilot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hocs/copilot.js b/src/hocs/copilot.js index 5ee83ad2..c5ffdb8b 100644 --- a/src/hocs/copilot.js +++ b/src/hocs/copilot.js @@ -180,7 +180,7 @@ const copilot = ({ async moveToCurrentStep(): void { const size = await this.state.currentStep.target.measure(); - + if (typeof verticalOffset === "function") verticalOffset = await verticalOffset(); await this.modal.animateMove({ width: size.width + OFFSET_WIDTH, height: size.height + OFFSET_WIDTH, From 4fe328a099703f8990cb36f0ce0058431ea8015e Mon Sep 17 00:00:00 2001 From: Benjamin Adzovic Novak Date: Tue, 16 Jun 2020 11:03:40 +0100 Subject: [PATCH 2/2] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 413bacd2..469d2fc0 100644 --- a/README.md +++ b/README.md @@ -276,6 +276,8 @@ copilot({ })(RootComponent); ``` +`verticalOffset` supports constant values, promises and functions as valid arguments + ### Triggering the tutorial Use `this.props.start()` in the root component in order to trigger the tutorial. You can either invoke it with a touch event or in `componentDidMount`. Note that the component and all its descendants must be mounted before starting the tutorial since the `CopilotStep`s need to be registered first.