Skip to content

Instantly share code, notes, and snippets.

@john45traver
Last active August 29, 2015 14:00
Show Gist options
  • Save john45traver/11310525 to your computer and use it in GitHub Desktop.
Save john45traver/11310525 to your computer and use it in GitHub Desktop.
class JTTrueSizeSurface
@DEFAULT_OPTIONS = {}
JTTrueSizeSurface.prototype = Object.create(Surface.prototype)
JTTrueSizeSurface.prototype.constructor = JTTrueSizeSurface
constructor: (id) ->
@id = id
Surface.apply(this, arguments)
@size = this.getSize()
getSize: () =>
return @size
deploy: (target) =>
content = this.getContent()
@target = target
if (content instanceof Node)
while (target.hasChildNodes())
target.removeChild(target.firstChild)
target.appendChild(content)
else target.innerHTML = content
width = if @size[0] == true then @target.offsetWidth else @size[0]
height = if @size[1] == true then @target.offsetHeight else @size[1]
@size = [width,height]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment