Skip to content

added support for a max slider value callback #36

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
*.zip
gh-pages
gh-pages
.idea/
20 changes: 20 additions & 0 deletions js/simple-slider.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@
# Revert the cursor
$("body").css cursor: "auto"

if @hasExceededMaximumValue
@hasExceededMaximumValue = false
@track.removeClass "out-of-bounds"
@setValue(@value)

# Set slider initial position
@pagePos = 0

Expand Down Expand Up @@ -201,6 +206,21 @@

# Trigger value changed events
value = @ratioToValue(ratio)

# ask if value is OK, value is changed to max if not good
eventData =
current_value: @value
new_value: value
el: @slider

@input.trigger('slider:confirm-value', eventData)
if eventData.new_value != value
@hasExceededMaximumValue = true
@track.addClass "out-of-bounds"
value = eventData.new_value
else
@track.removeClass "out-of-bounds"

@valueChanged(value, ratio, "domDrag")

# Update the position of the slider on the screen
Expand Down