Make the render expose its width and height

openid
Marcin Kulik 11 years ago
parent f0b66b6399
commit 20cf58e89b

@ -20,7 +20,7 @@ class AsciiIo.PlayerView extends Backbone.View
setupClipping: ->
if @options.containerWidth
rendererWidth = @rendererView.$el.outerWidth()
rendererWidth = @rendererView.elementWidth()
min = Math.min(@options.containerWidth, rendererWidth)
@rightClipWidth = rendererWidth - min
else

@ -10,6 +10,15 @@ class AsciiIo.Renderer.Base extends Backbone.View
@clearState()
requestAnimationFrame @render
width: ->
@cols * @cellWidth
height: ->
@lines * @cellHeight
elementWidth: ->
@$el.outerWidth()
clearState: ->
@state =
changes: {}

@ -12,11 +12,8 @@ class AsciiIo.Renderer.Canvas extends AsciiIo.Renderer.Base
@cursorVisible = true
fixTerminalElementSize: ->
width = @cols * @cellWidth
height = @lines * @cellHeight
@$el.attr('width', width)
@$el.attr('height', height)
@$el.attr('width', @width())
@$el.attr('height', @height())
@setFont()

@ -18,10 +18,7 @@ class AsciiIo.Renderer.Pre extends AsciiIo.Renderer.Base
i++
fixTerminalElementSize: ->
width = @cols * @cellWidth
height = @lines * @cellHeight
@$el.css(width: width + 'px', height: height + 'px')
@$el.css(width: @width() + 'px', height: @height() + 'px')
render: ->
if @state.dirty

Loading…
Cancel
Save