Hardware accelerate the piggy.

This improves the performance of the piggy animation by doing it in hardware
and eliminating a layout pass on every frame.

Change-Id: I02cf8b521af60af0e61f70c7f732f97074bdcdc1
This commit is contained in:
Aaron Boodman 2014-01-15 20:49:19 -08:00
parent 2d8c5992bf
commit 95f95a2623
1 changed files with 3 additions and 5 deletions

View File

@ -34,10 +34,8 @@ cam.SpritedImage = React.createClass({
if (y >= this.props.sheetHeight) { if (y >= this.props.sheetHeight) {
throw new Error(goog.string.subs('Index %s out of range', this.props.index)); throw new Error(goog.string.subs('Index %s out of range', this.props.index));
} }
return { var style = {};
position: 'absolute', style[cam.reactUtil.getVendorProp('transform')] = goog.string.subs('translate3d(%spx, %spx, 0)', -x * this.props.spriteWidth, -y * this.props.spriteHeight);
left: -x * this.props.spriteWidth, return style;
top: -y * this.props.spriteHeight
};
} }
}); });