Last active
December 28, 2015 02:59
-
-
Save xiujunma/7431704 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ember.CanvasView = Ember.View.extend({ | |
tagName: 'canvas', | |
attributeBindings: ['width', 'height'], | |
content: null, | |
width: 400, | |
height: 100, | |
clipsCanvasToDrawRect: true, | |
clippingRect: null, | |
redrawScheduled: false, | |
init: function () { | |
this._super(); | |
}, | |
context2d: function (key, value) { | |
var element = this.get('element'); | |
return element.getContext('2d'); | |
}.property(), | |
didInsertElement: function () { | |
this._super(); | |
this.draw(); | |
}, | |
contentDidChange: Ember.observer(function () { | |
this.clean(); | |
this.draw(); | |
}, 'content'), | |
draw: function () { | |
Ember.Logger.debug("Need be implemented"); | |
}, | |
clean: function () { | |
var w = this.get('width'), h = this.get('height'), ctx = this.get('context2d'); | |
ctx.clearRect(0, 0, w, h); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment