Made iPad touch events work on inventory equipping and progress slider.

This commit is contained in:
Nick Winter 2014-10-27 13:32:25 -07:00
parent 5d37e4d34e
commit f86c726fc8
3 changed files with 29 additions and 2 deletions

View file

@ -16,7 +16,9 @@ module.exports = class InventoryView extends CocoView
'click .item-slot': 'onItemSlotClick'
'click #available-equipment .list-group-item:not(.equipped)': 'onAvailableItemClick'
'dblclick #available-equipment .list-group-item:not(.equipped)': 'onAvailableItemDoubleClick'
'doubletap #available-equipment .list-group-item:not(.equipped)': 'onAvailableItemDoubleClick'
'dblclick .item-slot .item-view': 'onEquippedItemDoubleClick'
'doubletap .item-slot .item-view': 'onEquippedItemDoubleClick'
subscriptions:
'level:hero-selection-updated': 'onHeroSelectionUpdated'

View file

@ -41,6 +41,9 @@ module.exports = class LevelPlaybackView extends CocoView
'mouseenter #timeProgress': 'onProgressEnter'
'mouseleave #timeProgress': 'onProgressLeave'
'mousemove #timeProgress': 'onProgressHover'
'tapstart #timeProgress': 'onProgressTapStart'
'tapend #timeProgress': 'onProgressTapEnd'
'tapmove #timeProgress': 'onProgressTapMove'
shortcuts:
'⌘+p, p, ctrl+p': 'onTogglePlay'
@ -276,9 +279,9 @@ module.exports = class LevelPlaybackView extends CocoView
onProgressLeave: (e) ->
@timePopup?.leave @timePopup
onProgressHover: (e) ->
onProgressHover: (e, offsetX) ->
timeRatio = @$progressScrubber.width() / @totalTime
offsetX = e.clientX - $(e.target).closest('#timeProgress').offset().left
offsetX ?= e.clientX - $(e.target).closest('#timeProgress').offset().left
@newTime = offsetX / timeRatio
@updatePopupContent()
@timePopup?.onHover e
@ -287,6 +290,27 @@ module.exports = class LevelPlaybackView extends CocoView
if @timePopup and Math.abs(@currentTime - @newTime) < 1 and not @timePopup.shown
@timePopup.show()
onProgressTapStart: (e, touchData) ->
return unless application.isIPadApp
@onProgressEnter e
screenOffsetX = e.clientX ? touchData?.position.x ? 0
offsetX = screenOffsetX - $(e.target).closest('#timeProgress').offset().left
offsetX = Math.max offsetX, 0
@scrubTo offsetX / @$progressScrubber.width()
@onTogglePlay() if @$el.find('#play-button').hasClass 'playing'
onProgressTapEnd: (e, touchData) ->
return unless application.isIPadApp
@onProgressLeave e
onProgressTapMove: (e, touchData) ->
return unless application.isIPadApp # Not sure why the tap events would fire when it's not one.
screenOffsetX = e.clientX ? touchData?.position.x ? 0
offsetX = screenOffsetX - $(e.target).closest('#timeProgress').offset().left
offsetX = Math.max offsetX, 0
@onProgressHover e, offsetX
@scrubTo offsetX / @$progressScrubber.width()
updateProgress: (progress, world) ->
if world.frames.length isnt @lastLoadedFrameCount
@updateBarWidth world.frames.length, world.maxTotalFrames, world.dt

View file

@ -64,6 +64,7 @@ exports.config =
'bower_components/fastclick/lib/fastclick.js'
'bower_components/d3/d3.min.js'
'vendor/scripts/async.js'
'vendor/scripts/jquery-ui-1.11.1.js.custom.js'
]
stylesheets:
defaultExtension: 'sass'