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

noUiSlider implementation #2712

Merged
merged 12 commits into from
Feb 22, 2020
Merged

Conversation

ibdafna
Copy link
Member

@ibdafna ibdafna commented Jan 9, 2020

WIP PR for the new slider implementation.

Fixes #630

Todo:

  1. Additional testing of single-handle slider logic
  2. Kernel-side valiation of model.value so it is consistent with min/max and step (as discussed)
  3. Styling (current visuals are different from the JQuery-UI implementation
  4. Rewrite dual-handle slider functions to use noUiSlider (almost done)

@jasongrout
Copy link
Member

With this: widgets.IntSlider(orientation='vertical'), it used to be that min was at the bottom and max was at the top. Now it's reversed so that min is at the top and the max is at the bottom.

@jasongrout
Copy link
Member

widgets.IntSlider(style={'handle_color': 'red'}) no longer styles the handle red.

@jasongrout
Copy link
Member

@ibdafna - I'm just playing around with this and making notes where I see issues.

@jasongrout
Copy link
Member

jasongrout commented Feb 11, 2020

It feels like the slider thumb is just slightly off-center from its track. It feels like it is a pixel or two too high.
Screen Shot 2020-02-11 at 12 35 11 PM

Edit: I just measured. It's one pixel too high.

@jasongrout
Copy link
Member

@ibdafna has already pointed this out, but I'll note it here to make sure we take another look: widgets.FloatLogSlider() is extremely laggy compared to before. Grab the thumb and drag it around, and you see the thumb is very slow to update.

@jasongrout
Copy link
Member

Stylistically, the range region used to be much thicker with widgets.IntRangeSlider()

Before:
Screen Shot 2020-02-11 at 12 39 34 PM

After:
Screen Shot 2020-02-11 at 12 39 54 PM

@jasongrout
Copy link
Member

Just like with the FloatLogSlider, widgets.SelectionRangeSlider(options=range(10), value=(2,4)) is very laggy when dragging a thumb compared to before.

@jasongrout
Copy link
Member

For the lagginess, I tried turning off animation in some cases:

diff --git a/packages/controls/src/widget_float.ts b/packages/controls/src/widget_float.ts
index 2aee38fb8..94503c90f 100644
--- a/packages/controls/src/widget_float.ts
+++ b/packages/controls/src/widget_float.ts
@@ -147,13 +147,14 @@ class FloatLogSliderView extends BaseIntSliderView {
             log_value = min;
         }
 
-        return log_value
+        return log_value;
     }
 
     createSlider() {
         console.log("Twitter");
         noUiSlider.create(this.$slider, {
             start: this.logCalc(this.model.get('value')),
+            animate: this.model.get('max') % 2 === 0,
             connect: this.connect,
             range: {
                 'min': this.model.get('min'),
diff --git a/packages/controls/src/widget_int.ts b/packages/controls/src/widget_int.ts
index 43665d2be..cabbee91f 100644
--- a/packages/controls/src/widget_int.ts
+++ b/packages/controls/src/widget_int.ts
@@ -228,6 +228,7 @@ abstract class BaseIntSliderView extends DescriptionView {
         noUiSlider.create(this.$slider, {
             start: this.model.get('value'),
             connect: this.connect,
+            animate: this.model.get('max') % 2 === 0,
             range: {
                 'min': this.model.get('min'),
                 'max': this.model.get('max')
diff --git a/packages/controls/src/widget_selection.ts b/packages/controls/src/widget_selection.ts
index 4369564bb..f2335f4f8 100644
--- a/packages/controls/src/widget_selection.ts
+++ b/packages/controls/src/widget_selection.ts
@@ -686,6 +686,7 @@ class SelectionSliderView extends DescriptionView {
         noUiSlider.create(this.$slider, {
             start: this.model.get('index'),
             connect: true,
+            animate: max % 2 === 0,
             range: {
                 'min': min,
                 'max': max

It made a world of difference (just try doing FloatSlider(max=9) vs FloatSlider(max=10)). I know the animation looks cool, but I think we ought to turn it off until we can figure out how to avoid the lagginess.

@ibdafna
Copy link
Member Author

ibdafna commented Feb 12, 2020

Just did another round of testing. Outstanding issues:

  1. Finish fixing horizontal orientation CSS. The alignment seems to change too between some of the slider types - will investigate in the morning.
  2. Fix disabled mode CSS. It is not clear from the styling that the handles are disabled, which may cause confusion.
  3. Not passing a step value still seems to default to a step of 0.1 on the frontend. Will also investigate in the morning.

All other functionality seems to be working fine!

@jasongrout
Copy link
Member

Not passing a step value still seems to default to a step of 0.1 on the frontend. Will also investigate in the morning.

I think that is intentional? The attribute specification says that 0.1 is the default step for a float slider.

@jasongrout
Copy link
Member

Also finish fixing the thickening of the connection between range slider handles for the horizontal case.

@ibdafna
Copy link
Member Author

ibdafna commented Feb 13, 2020

Changed some of the function signatures to accept the updated_view attribute. This is now used to validate whether the slider should update its value when the updateSliderValue callback is invoked. This now enables smooth animations with no lags - shall we revisit this before merging?

@jasongrout
Copy link
Member

shall we revisit this before merging?

Sure, let's look at it tomorrow. Thanks for looking into it!

@jasongrout jasongrout merged commit 1479bea into jupyter-widgets:master Feb 22, 2020
@jasongrout jasongrout changed the title [WIP] noUiSlider implementation noUiSlider implementation Feb 22, 2020
@jasongrout
Copy link
Member

Thanks so much for your hard work on this!

@SylvainCorlay
Copy link
Member

Congrats @ibdafna !

@martinRenou
Copy link
Member

Thanks a lot @ibdafna ! Awesome work

@lock lock bot added the resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label May 20, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backwards-incompatible resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Non-jquery slider
4 participants