Skip to content

Commit

Permalink
reset at master
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur committed Jun 1, 2018
1 parent 6db1b1d commit 4377457
Showing 1 changed file with 35 additions and 37 deletions.
72 changes: 35 additions & 37 deletions dist/fabric.js
Original file line number Diff line number Diff line change
Expand Up @@ -11844,7 +11844,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fab
this.setCursor(this.defaultCursor);
// clear selection and current transformation
this._groupSelector = null;
this._currentTransform = null;
}
});

Expand Down Expand Up @@ -14245,13 +14244,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
_getLeftTopCoords: function() {
return this.translateToOriginPoint(this.getCenterPoint(), 'left', 'top');
},

/**
* Callback; invoked right before object is about to go from active to inactive
*/
onDeselect: function() {
/* NOOP */
}
});

})();
Expand Down Expand Up @@ -25016,7 +25008,8 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
leftOffset = this._getLeftOffset(),
topOffset = this._getTopOffset(), top,
boxStart, boxWidth, charBox, currentDecoration,
maxHeight, currentFill, lastFill;
maxHeight, currentFill, lastFill,
charSpacing = this._getWidthOfCharSpacing();

for (var i = 0, len = this._textLines.length; i < len; i++) {
heightOfLine = this.getHeightOfLine(i);
Expand Down Expand Up @@ -25064,7 +25057,7 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
currentDecoration && currentFill && ctx.fillRect(
leftOffset + lineLeftOffset + boxStart,
top + this.offsets[type] * size + dy,
boxWidth,
boxWidth - charSpacing,
this.fontSize / 15
);
topOffset += heightOfLine;
Expand Down Expand Up @@ -25976,18 +25969,19 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
return this.cursorOffsetCache;
}
var lineLeftOffset,
lineIndex = 0,
charIndex = 0,
lineIndex,
charIndex,
topOffset = 0,
leftOffset = 0,
boundaries,
cursorPosition = this.get2DCursorLocation(position);
for (var i = 0; i < cursorPosition.lineIndex; i++) {
charIndex = cursorPosition.charIndex;
lineIndex = cursorPosition.lineIndex;
for (var i = 0; i < lineIndex; i++) {
topOffset += this.getHeightOfLine(i);
}

lineLeftOffset = this._getLineLeftOffset(cursorPosition.lineIndex);
var bound = this.__charBounds[cursorPosition.lineIndex][cursorPosition.charIndex];
lineLeftOffset = this._getLineLeftOffset(lineIndex);
var bound = this.__charBounds[lineIndex][charIndex];
bound && (leftOffset = bound.left);
if (this.charSpacing !== 0 && charIndex === this._textLines[lineIndex].length) {
leftOffset -= this._getWidthOfCharSpacing();
Expand Down Expand Up @@ -26064,7 +26058,9 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
boxEnd = this.__charBounds[endLine][endChar].left;
}
else {
boxEnd = this.__charBounds[endLine][endChar - 1].left + this.__charBounds[endLine][endChar - 1].width;
var charSpacing = this._getWidthOfCharSpacing();
boxEnd = this.__charBounds[endLine][endChar - 1].left
+ this.__charBounds[endLine][endChar - 1].width - charSpacing;
}
}
realLineHeight = lineHeight;
Expand Down Expand Up @@ -26164,10 +26160,9 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
this.mouseMoveHandler = this.mouseMoveHandler.bind(this);
},

onDeselect: function(options) {
onDeselect: function() {
this.isEditing && this.exitEditing();
this.selected = false;
fabric.Object.prototype.onDeselect.call(this, options);
},

/**
Expand Down Expand Up @@ -26208,13 +26203,13 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) {
* @private
*/
_initCanvasHandlers: function(canvas) {
canvas._mouseUpITextHandler = (function() {
canvas._mouseUpITextHandler = function() {
if (canvas._iTextInstances) {
canvas._iTextInstances.forEach(function(obj) {
obj.__isMousedown = false;
});
}
}).bind(this);
};
canvas.on('mouse:up', canvas._mouseUpITextHandler);
},

Expand Down Expand Up @@ -27080,7 +27075,7 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot

this.__lastPointer = { };

this.on('mousedown', this.onMouseDown.bind(this));
this.on('mousedown', this.onMouseDown);
},

/**
Expand All @@ -27092,7 +27087,7 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
return;
}
this.__newClickTime = +new Date();
var newPointer = this.canvas.getPointer(options.e);
var newPointer = options.pointer;
if (this.isTripleClick(newPointer)) {
this.fire('tripleclick', options);
this._stopEvent(options.e);
Expand Down Expand Up @@ -27150,10 +27145,7 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
if (!this.canvas || !this.editable || (options.e.button && options.e.button !== 1)) {
return;
}
var pointer = this.canvas.getPointer(options.e);

this.__mousedownX = pointer.x;
this.__mousedownY = pointer.y;
this.__isMousedown = true;

if (this.selected) {
Expand All @@ -27170,21 +27162,25 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
},

/**
* Initializes "mousedown" event handler
* Default event handler for the basic functionalities needed on mousedown:before
* can be overridden to do something different.
* Scope of this implementation is: verify the object is already selected when mousing down
*/
initMousedownHandler: function() {
this.on('mousedown', this._mouseDownHandler);
_mouseDownHandlerBefore: function(options) {
if (!this.canvas || !this.editable || (options.e.button && options.e.button !== 1)) {
return;
}
if (this === this.canvas._activeObject) {
this.selected = true;
}
},

/**
* detect if object moved
* @private
* Initializes "mousedown" event handler
*/
_isObjectMoved: function(e) {
var pointer = this.canvas.getPointer(e);

return this.__mousedownX !== pointer.x ||
this.__mousedownY !== pointer.y;
initMousedownHandler: function() {
this.on('mousedown', this._mouseDownHandler);
this.on('mousedown:before', this._mouseDownHandlerBefore);
},

/**
Expand All @@ -27200,7 +27196,9 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
*/
mouseUpHandler: function(options) {
this.__isMousedown = false;
if (!this.editable || this._isObjectMoved(options.e) || (options.e.button && options.e.button !== 1)) {
if (!this.editable ||
(options.transform && options.transform.actionPerformed) ||
(options.e.button && options.e.button !== 1)) {
return;
}

Expand Down

0 comments on commit 4377457

Please sign in to comment.