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

Question: How use ScrollView in SpotlightTourProvider #136

Open
onethps opened this issue Dec 22, 2023 · 3 comments
Open

Question: How use ScrollView in SpotlightTourProvider #136

onethps opened this issue Dec 22, 2023 · 3 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@onethps
Copy link

onethps commented Dec 22, 2023

How to use a ScrollView in SpotlightTourProvider? I have Attached step into scrollView at the bottom
Screenshot 2023-12-22 at 10 00 23

@JoseLion
Copy link
Member

This is one of the main reasons we added the before(..) hook on the step configuration. You can programmatically scroll to a specific position on the screen before the step starts. And because the before(..) hook accepts a promise, you can add as much delay as you want to wait for the scroll to reach the expected position.

function delay(ms: number): Promise<void> {
  return new Promise(resolve => {
    setTimeout(resolve, ms);
  });
}

const steps = [
  {
  ...restOfstep,
  before: () => {
    scrollRef.current?.scrollTo({ x: 0, y: 120, animated: true });

    return delay(1500); // delay 1.5s
  },
]

This brings a few ideas to improve things around. We could add something to help go over this scenario more smoothly. I'll be looking into this. Thanks for the report! 🙂

@JoseLion JoseLion added enhancement New feature or request question Further information is requested labels Jan 26, 2024
@wheeler-cleo
Copy link

This is one of the main reasons we added the before(..) hook on the step configuration. You can programmatically scroll to a specific position on the screen before the step starts. And because the before(..) hook accepts a promise, you can add as much delay as you want to wait for the scroll to reach the expected position.

function delay(ms: number): Promise<void> {
  return new Promise(resolve => {
    setTimeout(resolve, ms);
  });
}

const steps = [
  {
  ...restOfstep,
  before: () => {
    scrollRef.current?.scrollTo({ x: 0, y: 120, animated: true });

    return delay(1500); // delay 1.5s
  },
]

This brings a few ideas to improve things around. We could add something to help go over this scenario more smoothly. I'll be looking into this. Thanks for the report! 🙂

@JoseLion is there a recommended pattern to define steps from within a child component. For example, in this structure:

// App.tsx
<SpotlightTourProvider>
  <HomeScreen />
</SpotlightTourProvider>

Is it possible to define steps directly within the HomeScreen component?

My use case would be so that I can pass a ref of an element within the HomeScreen directly to a step, without needing to pass the ref up to the App.tsx file.

I've been looking through the source code and wasn't sure if there was a better way of handling this.

Thanks in advance!

@julien9999
Copy link

any suggestion @JoseLion on how best to implement?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants