Refactor properties into methods for viewport

This commit is contained in:
Erik Tiekstra
2017-05-12 10:32:39 +02:00
parent 54a7a7e6ba
commit 4544b96093
6 changed files with 33 additions and 38 deletions
+14 -21
View File
@@ -117,32 +117,25 @@ function Viewport(canvas) {
this.set = function (width, height) {
_data = util.calcCrop(canvas.getImage(), width, height);
apply();
this.gores.reset();
this.rulers.reset();
this.getGores().reset();
this.getRulers().reset();
canvas.getApertures().setTransparent(true);
canvas.getImage().__moved = false;
canvas.getButtonMenu().bringToFront();
};
util.setProperties(this, {
data: {
get: function () {
return _data;
}
},
gores: {
get: function () {
return this.__goreHandler ||
(this.__goreHandler = new GoreHandler(this));
}
},
rulers: {
get: function () {
return this.__rulerHandler ||
(this.__rulerHandler = new RulerHandler(this));
}
}
});
this.getCropData = function () {
return _data;
};
this.getGores = function () {
return this.__goreHandler || (this.__goreHandler = new GoreHandler(this));
};
this.getRulers = function () {
return this.__rulerHandler || (this.__rulerHandler = new RulerHandler(this));
};
}
module.exports = Viewport;