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

Suggestion - Plug-able mode option #30

Closed
roderickhsiao opened this issue Jul 3, 2020 · 2 comments
Closed

Suggestion - Plug-able mode option #30

roderickhsiao opened this issue Jul 3, 2020 · 2 comments

Comments

@roderickhsiao
Copy link
Contributor

Thanks for the awesome library.

One suggestion here is for the mode option,

function moveWithSpeed() {
    hook('beforeChange')
    switch (options.mode) {
      case 'free':
        moveFree()
        break
      case 'free-snap':
        moveSnapFree()
        break
      case 'snap':
      default:
        moveSnapOne()
        break
    }
  }

wondering if we can make it pluggable so only the default one will be built in, and the library could export other mode such as

import { freesnap }, KeenSlider from 'keen-slider';

const slider = new KeenSlider('#my-slider', {
  loop: true,
  modeFunc: freesnap
});

In this case its easier to tree-shake methods the people are not using it and reduce the overall bundle size.
It might not be totally easy to implement without refactor as most of the function are written accessing global variable, just throwing some idea to make the library more flexible.

Cheers

@roderickhsiao roderickhsiao changed the title Suggestion - Plug-able mode Suggestion - Plug-able mode option Jul 3, 2020
@rcbyr
Copy link
Owner

rcbyr commented Jul 3, 2020

Hey @roderickhsiao

thank you very much!

I like the idea of making the library more modular. I'm hoping to have some time over the next weeks to rewrite the whole movement and animation part. I think I can get a lot more out of it and will definitely consider your suggestion.

Since I want to make the slider available for react-native, I have to make some changes anyway.

@rcbyr rcbyr closed this as completed Jul 7, 2020
@jayphelps
Copy link

@rcbyr is there still appetite for this? We'd be willing to contribute a PR if so.

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

3 participants