Fixed more off-by-one errors in playback ratios. Fixed some clickability problems with the scrubber handle.

This commit is contained in:
Nick Winter 2014-09-24 21:01:58 -07:00
parent b8d59cb179
commit b2592aad8c
4 changed files with 12 additions and 8 deletions

View file

@ -249,7 +249,7 @@ module.exports = Surface = class Surface extends CocoClass
createjs.Tween.removeTweens(@)
@currentFrame = @scrubbingTo
@scrubbingTo = Math.min(Math.round(progress * @world.frames.length), @world.frames.length)
@scrubbingTo = Math.min(Math.round(progress * (@world.frames.length - 1)), @world.frames.length - 1)
@scrubbingPlaybackSpeed = Math.sqrt(Math.abs(@scrubbingTo - @currentFrame) * @world.dt / (scrubDuration or 0.5))
if scrubDuration
t = createjs.Tween
@ -433,7 +433,7 @@ module.exports = Surface = class Surface extends CocoClass
@setWorld event.world
@onFrameChanged(true)
fastForwardBuffer = 2
if @playing and not @realTime and (ffToFrame = Math.min(event.firstChangedFrame, @frameBeforeCast, @world.frames.length)) and ffToFrame > @currentFrame + fastForwardBuffer * @world.frameRate
if @playing and not @realTime and (ffToFrame = Math.min(event.firstChangedFrame, @frameBeforeCast, @world.frames.length - 1)) and ffToFrame > @currentFrame + fastForwardBuffer * @world.frameRate
@fastForwardingToFrame = ffToFrame
@fastForwardingSpeed = Math.max 4, 4 * 90 / (@world.maxTotalFrames * @world.dt)
else if @realTime

View file

@ -123,7 +123,7 @@ $level-resize-transition-time: 0.5s
.gradient
position: absolute
z-index: 10
z-index: 5
#code-area-gradient
top: 0px

View file

@ -100,25 +100,29 @@
// Can't do this transition because handle then jitters, but would be good for streaming.
//@include transition(width .2s linear)
&.disabled
&.disabled, &.ui-slider-disabled
cursor: default
.progress-bar .scrubber-handle
cursor: default
.progress-bar
@include transition(width .0s linear)
position: relative
pointer-events: none
// Remove gradient background in favor of solid fill
background-color: #67A4C8
//background-image: none // gradient looks kind of cool though; keep it in
.scrubber-handle
cursor: pointer
position: absolute
pointer-events: none
right: -16px
top: -9px
background: transparent url(/images/level/playback_thumb.png)
width: 32px
height: 32px
// z: above the gradient line bordering the playback bar
z-index: 6
.ui-slider-handle
height: 100%

View file

@ -179,8 +179,8 @@ module.exports = class LevelPlaybackView extends CocoView
@updateBarWidth e.world.frames.length, e.world.maxTotalFrames, e.world.dt
updateBarWidth: (loadedFrameCount, maxTotalFrames, dt) ->
@totalTime = loadedFrameCount * dt
pct = parseInt(100 * loadedFrameCount / maxTotalFrames) + '%'
@totalTime = (loadedFrameCount - 1) * dt
pct = parseInt(100 * loadedFrameCount / (maxTotalFrames - 1)) + '%'
@barWidth = $('.progress', @$el).css('width', pct).show().width()
$('.scrubber .progress', @$el).slider('enable', true)
@newTime = 0