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

Reversed slider #1504

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/nodes/widgets/ui-slider.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ props:
description: Defined when the ticks will be visible on the track. Defaults to 'Always'.
dynamic: true
Range:
description: min - the minimum value the slider can be changed to; max - the maximum value the slider can be changed to; step - the increment/decrement value when the slider is moved.
description: min - the minimum value the slider can be changed to. When min > max then the slider will be reverted.; max - the maximum value the slider can be changed to; step - the increment/decrement value when the slider is moved.
joepavitt marked this conversation as resolved.
Show resolved Hide resolved
dynamic: true
Color:
description: main - color of the slider and thumb; track - color of the slider track; thumb - color of the handle. It could be the name of a color (red, green, blue, ...) or a Hex color code (#b5b5b5).
Expand Down
2 changes: 1 addition & 1 deletion nodes/widgets/locales/en-US/ui_slider.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h3>Dynamic Properties (Inputs)</h3>
</dl>
<dl class="message-properties">
<dt class="optional">min <span class="property-type">number</span></dt>
<dd>The minimum value available on the slider.</dd>
<dd>The minimum value available on the slider. When the minimum value is larger than the maximum value, the slider will be reversed.</dd>
</dl>
<dl class="message-properties">
<dt class="optional">step <span class="property-type">number</span></dt>
Expand Down
8 changes: 6 additions & 2 deletions ui/src/widgets/ui-slider/UISlider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
:thumb-label="thumbLabel"
:append-icon="iconAppend" :prepend-icon="iconPrepend"
:min="min" :direction="direction"
:reverse="isReverse"
:tick-size="4" :track-size="4"
:color="color" :track-color="colorTrack" :thumb-color="colorThumb"
:max="max" :step="step || 1" :show-ticks="showTicks"
Expand Down Expand Up @@ -61,13 +62,16 @@ export default {
return this.getProperty('showTicks')
},
min: function () {
return this.getProperty('min')
return Math.min(this.getProperty('min'), this.getProperty('max'))
},
step: function () {
return this.getProperty('step')
},
max: function () {
return this.getProperty('max')
return Math.max(this.getProperty('min'), this.getProperty('max'))
},
isReverse: function () {
return this.getProperty('min') > this.getProperty('max')
},
iconPrepend: function () {
const icon = this.getProperty('iconPrepend')
Expand Down