Make the render expose its width and height

This commit is contained in:
Marcin Kulik 2013-06-12 23:58:24 +02:00
parent f0b66b6399
commit 20cf58e89b
4 changed files with 13 additions and 10 deletions

View File

@ -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

View File

@ -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: {}

View File

@ -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()

View File

@ -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