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 an option to define the width in which SlidingDot operates #22

Open
luixo opened this issue Jan 16, 2023 · 2 comments
Open

Add an option to define the width in which SlidingDot operates #22

luixo opened this issue Jan 16, 2023 · 2 comments

Comments

@luixo
Copy link

luixo commented Jan 16, 2023

Currently SlidingDot operates on the screen width, though I'm using it on a card with images being narrower than a window width.

On image scroll I have to replace

onProgressChange={(offsetProgress) => scrollX.setValue(-offsetProgress)}

with

onProgressChange={(offsetProgress) =>
  scrollX.setValue(
    -offsetProgress * (windowWidth / imageWidth)
    + (windowWidth - imageWidth) * (MARGIN_SIZE / windowWidth)
  )
}
// ...
<SlidingDot marginHorizontal={MARGIN_SIZE} {...otherProps} />

Giving an ability to change the inputRange to [-imageWidth, 0, imageWidth] I'll be able to skip this sophisticated scaling.

@priami93
Copy link

priami93 commented Aug 5, 2023

Excellent observation.
for the ExpandingDot component I added the property

itemWidth?: number;

and modified

const inputRange = [
    (index - 1) * width,
    index * width,
    (index + 1) * width,
];

in

const inputRange = [
    (index - 1) * (itemWidth || width),
    index * (itemWidth || width),
    (index + 1) * (itemWidth || width),
];

Now I use

<ExpandingDot
   data={items}
    ...
   itemWidth={myItemWidth}
/>

@luixo
Copy link
Author

luixo commented Aug 14, 2023

@weahforsage
What do you think on that problem?
Can you approve the idea so the PR may be opened?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants