2013-11-01 18:39:42 +04:00
|
|
|
(function () {
|
|
|
|
var ns = $.namespace('pskl.rendering.frame');
|
|
|
|
|
|
|
|
/**
|
2013-11-01 19:27:23 +04:00
|
|
|
* FrameRenderer implementation that prevents unnecessary redraws.
|
2013-11-01 18:39:42 +04:00
|
|
|
* @param {HtmlElement} container HtmlElement to use as parentNode of the Frame
|
|
|
|
* @param {Object} renderingOptions
|
|
|
|
* @param {Array} classes array of strings to use for css classes
|
|
|
|
*/
|
|
|
|
ns.CachedFrameRenderer = function (container, renderingOptions, classes) {
|
2013-11-01 19:27:23 +04:00
|
|
|
pskl.rendering.frame.FrameRenderer.call(this, container, renderingOptions, classes);
|
|
|
|
this.serializedFrame = '';
|
2013-11-01 18:39:42 +04:00
|
|
|
};
|
|
|
|
|
2013-11-01 19:27:23 +04:00
|
|
|
pskl.utils.inherit(pskl.rendering.frame.CachedFrameRenderer, pskl.rendering.frame.FrameRenderer);
|
2013-11-01 18:39:42 +04:00
|
|
|
|
2013-11-01 19:27:23 +04:00
|
|
|
ns.CachedFrameRenderer.prototype.render = function (frame) {
|
|
|
|
var offset = this.getOffset();
|
|
|
|
var size = this.getDisplaySize();
|
2013-11-05 03:05:49 +04:00
|
|
|
var serializedFrame = [
|
|
|
|
this.getZoom(),
|
|
|
|
this.isGridEnabled(),
|
|
|
|
offset.x, offset.y,
|
|
|
|
size.width, size.height,
|
|
|
|
frame.serialize()
|
|
|
|
].join('-');
|
2013-11-01 19:27:23 +04:00
|
|
|
if (this.serializedFrame != serializedFrame) {
|
|
|
|
this.serializedFrame = serializedFrame;
|
|
|
|
this.superclass.render.call(this, frame);
|
|
|
|
}
|
|
|
|
};
|
2013-11-01 18:39:42 +04:00
|
|
|
})();
|