HTML and CSS Reference
In-Depth Information
Q.DOMSprite = Q.Sprite.extend({
init: function(props) {
this._super(props);
this.el = $("<div>").css({
width: this.p.w,
height: this.p.h,
zIndex: this.p.z || 0,
position: 'absolute'
});
this.dom = this.el[0];
this.rp = {};
this.setImage();
this.setTransform();
},
setImage: function() {
var asset;
if(this.sheet()) {
asset = Q.asset(this.sheet().asset);
} else {
asset = this.asset();
}
if(asset) {
this.dom.style.backgroundImage = "url(" + asset.src + ")";
}
},
setTransform: function() {
var p = this.p;
var rp = this.rp;
if(rp.frame !== p.frame) {
if(p.sheet) {
this.dom.style.backgroundPosition =
(-this.sheet().fx(p.frame)) + "px " +
(-this.sheet().fy(p.frame)) + "px";
} else {
this.dom.style.backgroundPosition = "0px 0px";
}
rp.frame = p.frame;
}
if(rp.x !== p.x || rp.y !== p.y) {
Q.positionDOM(this.dom,p.x,p.y);
rp.x = p.x;
rp.y = p.y;
}
},
Search WWH ::




Custom Search