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

feat(components): [slider] add mark-snap-percentage #16609

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

adapt0
Copy link

@adapt0 adapt0 commented Apr 22, 2024

  • while dragging slider; will snap value to the closest mark if value is within mark-snap-percentage (+/- in slider percent)
  • Snap percentage defaults to zero
  • can hold down control key while dragging to disable snapping behavior
  • added additional show-marks examples
  • generalized mouseDrag in slider tests

Motivation for this feature is to be able to drag the slider and easily hit the custom mark values. While a user could just click the mark's label, many users aren't aware of that functionality, and end up struggling to reach the desired mark value. For example a color temperature slider may have a range from 1000K to 10,000K with a default value of 6504K. Getting back to that default 6504K via dragging of the slider can be challenging. Have added this specific case to show-marks examples.

This is also opt-in where the default value of zero keeps previous behavior.

Code does assume that the number of marks will be low, so just performs a linear search of the marks for snapping.

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow contributing guide English | (中文 | Español | Français).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer to relative issues for your PR.

Copy link

👋 @adapt0, seems like this is your first time contribution to element-plus.

  • Please make sure that you have read our guidelines and code of conduct before making a contribution.
  • You can comment with /label Components:[component_name] to add a label for which component you are working on.
  • You may join our Discord for staying tuned.

@pull-request-triage pull-request-triage bot added 1st contribution Their very first contribution Needs Review labels Apr 22, 2024
Copy link

github-actions bot commented Apr 22, 2024

Copy link

Hello @adapt0, thank you for contributing to element-plus, please see our guideline to see how to make contribution

Copy link

🧪 Playground Preview: https://element-plus.run/?pr=16609
Please comment the example via this playground if needed.

* while dragging slider; will snap value to the closest mark if value is within mark-snap-percentage (+/- in slider percent)
* Snap percentage defaults to zero
* can hold down control key while dragging to disable snapping behavior
* added additional show-marks examples
* generalized mouseDrag in slider tests
@adapt0 adapt0 force-pushed the feat/slider/mark-snap-percentage branch from a411857 to e8b4abe Compare April 25, 2024 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant