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

Replace option align:number with a callback #594

Closed
1 task done
Tracked by #321
davidjerleke opened this issue Oct 10, 2023 Discussed in #579 · 0 comments · Fixed by #595
Closed
1 task done
Tracked by #321

Replace option align:number with a callback #594

davidjerleke opened this issue Oct 10, 2023 Discussed in #579 · 0 comments · Fixed by #595
Labels
feature request New feature or request

Comments

@davidjerleke
Copy link
Owner

davidjerleke commented Oct 10, 2023

Feature request is related to

  • embla-carousel (core package)

Describe the solution you'd like (discussed in #579)

Originally posted by davidjerleke September 25, 2023
@tobimori we could replace the number option with a callback function like so:

const options = {
  align: (viewSize, snapSize, index) => {
    // create your own alignment
    return yourCustomAlignment
  }
}

The benefit of this would be that you would have direct access to the size of the container (viewSize) and the current slide/slideGroup (itemSize) which is convenient because you don't have to read element dimensions yourself. Note that the function would run for each and every scroll snap. This would be even more flexible than the previous implementation and wouldn't affect bundle size.

@davidjerleke davidjerleke added the feature request New feature or request label Oct 10, 2023
@davidjerleke davidjerleke changed the title Replace option align: number with a callback Replace option align: number with a callback Oct 10, 2023
@davidjerleke davidjerleke changed the title Replace option align: number with a callback Replace option align:number with a callback Oct 10, 2023
davidjerleke added a commit that referenced this issue Oct 10, 2023
This was referenced Oct 10, 2023
davidjerleke added a commit that referenced this issue Oct 11, 2023
Replace option `align:number` with a callback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant