Skip to content

Commit

Permalink
fixed onMove issue prajwalkman#22, where eventX would return NaN if e…
Browse files Browse the repository at this point in the history
…vent.clientX was 0
  • Loading branch information
Julian Krispel-Samsel committed Nov 8, 2013
1 parent e926b07 commit 928103e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
27 changes: 10 additions & 17 deletions angular-slider.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion angular-slider.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions src/angular-slider.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ sliderDirective = ($timeout) ->
ngDocument.unbind events.move
ngDocument.unbind events.end
onMove = (event) ->
eventX = event.clientX || event.touches[0].clientX
if event['touches']
eventX = event.touches?[0].clientX
else
eventX = event.clientX
newOffset = eventX - element[0].getBoundingClientRect().left - pointerHalfWidth
newOffset = Math.max(Math.min(newOffset, maxOffset), minOffset)
newPercent = percentOffset newOffset
Expand Down Expand Up @@ -227,4 +230,4 @@ module = (window, angular) ->
.module(MODULE_NAME, [])
.directive(SLIDER_TAG, qualifiedDirectiveDefinition)

module window, window.angular
module window, window.angular

0 comments on commit 928103e

Please sign in to comment.