nickmcmillan / react-physics-dragger

A simple, no-frills horiztonal dragger/slider with physics
202 stars 10 forks source link

Feature Request: Ability to Page #10

Closed ccveer closed 5 years ago

ccveer commented 5 years ago

We would like to add buttons to page through the slider. Could this functionality be enabled? We are willing to do the work if you would be willing to accept the PR. Thanks!

nickmcmillan commented 5 years ago

I can certainly see the use for this, so I've had a stab at an implementation. I think the best way to be able to control the dragger programatically is by exposing some kind of API via a ref. Basically what this React component does with Flickity (note the <Flickity flickityRef={c => this.flkty = c}>): https://github.com/theolampert/react-flickity-component#readme

Take a look at Example1 in this branch I've created which now features +/- positioning buttons. Curious what you think and whether this the right approach?

https://github.com/nickmcmillan/react-physics-dragger/tree/feature/set-position

ccveer commented 5 years ago

I think it looks good, but could we add an edge checker? So that if you try to page past the edge of the slider, it slides back with friction?

ccveer commented 5 years ago

This looks great! Is there any chance this will be released soon?

nickmcmillan commented 5 years ago

Sorry it's taken a while to get here @ccveer ! I've completed some work and will create a PR now.

nickmcmillan commented 5 years ago

Ok merged. I've updated the docs too. Have deployed it to npm @1.2.0