Opened 7 years ago

Last modified 3 years ago

#10737 open feature

Slider: allow for easy modification of the default linear behaviour

Reported by: ssaki Owned by:
Priority: minor Milestone: none
Component: ui.slider Version: git (not yet released)
Keywords: Cc:
Blocked by: Blocking:


Currently there is no way to easy override the linear behavior of the slider. There are times where another visual behavior (e.g. logarithmic) is more appropriate.

Consider the following example scenario: having a price filter, represented by a range slider, for used cars site. Most of the items will be relatively evenly distributed into a given range, but if you add something with large deviation (e.g. Ferrari f50 among bunch of old) it will extend the range so much that the resolution in the lower range will become useless - one step of the slider will filter-out 50+% of the items. This is a common enough scenario to be addressed properly in a sane way.

Currently there in no option nor an extension point for that. The calculation code is located inside _refreshValue() and _mouseCapture() and the modification requires to extend the plugin and override all the code in those methods. As the calculations are only tiny fraction of them this would make maintenance painful.

It'd be better if the distance calculation code is located in separate methods thus allowing extending the plugin without the need to copy/paste all the unrelated (to the distance calculation) code in _refreshValue() and _mouseCapture() just to modify the handle progress/distance behaviour.

Additionally options may be introduced to hold a calculation callbacks that will default to plugin's own linear calculation methods. That way modifying plugins behavior will only require setting new callbacks which is even easier.

Modification in that way will not cause BC break as no existing method will change it's behaviour/API

Change History (4)

comment:1 Changed 7 years ago by ssaki

Created a PR with the suggested approach:

comment:2 Changed 7 years ago by tj.vantoll

Status: newopen
Summary: No extension point for easy modification of the default linear behaviourSlider: allow for easy modification of the default linear behaviour

I think this is a reasonable use case for an extension point so I'll mark this as valid for now.

comment:3 Changed 7 years ago by Alexander Schmitz

I think this should probably wait and be part of the pending slider re-write.

comment:4 Changed 3 years ago by Scott González

#15301 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.