Replaced h and v by x and y

This commit is contained in:
Erik Tiekstra
2017-06-01 09:28:02 +02:00
parent 103a17decf
commit c377532138
13 changed files with 86 additions and 97 deletions
+14 -14
View File
@@ -6,8 +6,8 @@ var config = require('./config');
function RulerHandler(viewport) {
var _enabled = false;
var _lines = { h: null, v: null };
var _rect = { h: null, v: null };
var _lines = { x: null, y: null };
var _rect = { x: null, y: null };
var Event = {
/**
@@ -35,15 +35,15 @@ function RulerHandler(viewport) {
var bounds = viewport.getBounds();
return new fabric.Line([
0, 0,
axis === 'h' ? bounds.width : 0,
axis === 'v' ? bounds.height : 0
axis === 'x' ? bounds.width : 0,
axis === 'y' ? bounds.height : 0
], {
evented: false,
strokeDashArray: [5, 5],
stroke: '#000',
strokeWidth: 1,
top: axis === 'h' ? bounds.top + bounds.height / 2 : bounds.top,
left: axis === 'v' ? bounds.left + bounds.width / 2 : bounds.left
top: axis === 'x' ? bounds.top + bounds.height / 2 : bounds.top,
left: axis === 'y' ? bounds.left + bounds.width / 2 : bounds.left
});
}
@@ -51,7 +51,7 @@ function RulerHandler(viewport) {
* @return {RulerHandler}
*/
this.clear = function () {
[].concat(_rect.h, _rect.v, _lines.h, _lines.v).forEach(function (o) {
[].concat(_rect.x, _rect.y, _lines.x, _lines.y).forEach(function (o) {
viewport.canvas.remove(o);
});
return this;
@@ -72,19 +72,19 @@ function RulerHandler(viewport) {
var bounds = viewport.getBounds();
_lines = { h: getLine('h'), v: getLine('v') };
_lines = { x: getLine('x'), y: getLine('y') };
viewport.canvas.add(_lines.h);
viewport.canvas.add(_lines.v);
viewport.canvas.add(_lines.x);
viewport.canvas.add(_lines.y);
_rect.h = new TextButton('horizontalRuler', 'H', config.rulerHandle)
.set(config.rulerHandle.h(_lines, bounds))
_rect.x = new TextButton('horizontalRuler', 'H', config.rulerHandle)
.set(config.rulerHandle.x(_lines, bounds))
.addTo(viewport.canvas)
.on('moving', Event.onMove)
.trigger('moving');
_rect.v = new TextButton('verticalRuler', 'V', config.rulerHandle)
.set(config.rulerHandle.v(_lines, bounds))
_rect.y = new TextButton('verticalRuler', 'V', config.rulerHandle)
.set(config.rulerHandle.y(_lines, bounds))
.addTo(viewport.canvas)
.on('moving', Event.onMove)
.trigger('moving');