mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-28 14:58:16 +00:00
Merge pull request #2068 from asturur/fix-jscs
attemp to fix jscs crash
This commit is contained in:
commit
e43ebdfea7
9 changed files with 78 additions and 77 deletions
|
|
@ -123,10 +123,10 @@ fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @lends fabric
|
||||||
this.canvas.renderAll();
|
this.canvas.renderAll();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} rects
|
* @param {Array} rects
|
||||||
*/
|
*/
|
||||||
_getOptimizedRects: function(rects) {
|
_getOptimizedRects: function(rects) {
|
||||||
|
|
||||||
// avoid creating duplicate rects at the same coordinates
|
// avoid creating duplicate rects at the same coordinates
|
||||||
|
|
|
||||||
|
|
@ -808,7 +808,7 @@
|
||||||
var target,
|
var target,
|
||||||
pointer = this.getPointer(e, true),
|
pointer = this.getPointer(e, true),
|
||||||
i = this._objects.length;
|
i = this._objects.length;
|
||||||
// Do not check for currently grouped objects, since we check the parent group itself.
|
// Do not check for currently grouped objects, since we check the parent group itself.
|
||||||
while (i--) {
|
while (i--) {
|
||||||
if (!this._objects[i].group && this._checkTarget(e, this._objects[i], pointer)){
|
if (!this._objects[i].group && this._checkTarget(e, this._objects[i], pointer)){
|
||||||
this.relatedTarget = this._objects[i];
|
this.relatedTarget = this._objects[i];
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@
|
||||||
data = imageData.data,
|
data = imageData.data,
|
||||||
tr, tg, tb,
|
tr, tg, tb,
|
||||||
r, g, b,
|
r, g, b,
|
||||||
|
_r, _g, _b,
|
||||||
source,
|
source,
|
||||||
isImage = false;
|
isImage = false;
|
||||||
|
|
||||||
|
|
@ -100,9 +101,9 @@
|
||||||
data[i + 2] = Math.abs(b - tb);
|
data[i + 2] = Math.abs(b - tb);
|
||||||
break;
|
break;
|
||||||
case 'subtract':
|
case 'subtract':
|
||||||
var _r = r - tr,
|
_r = r - tr;
|
||||||
_g = g - tg,
|
_g = g - tg;
|
||||||
_b = b - tb;
|
_b = b - tb;
|
||||||
|
|
||||||
data[i] = (_r < 0) ? 0 : _r;
|
data[i] = (_r < 0) ? 0 : _r;
|
||||||
data[i + 1] = (_g < 0) ? 0 : _g;
|
data[i + 1] = (_g < 0) ? 0 : _g;
|
||||||
|
|
|
||||||
|
|
@ -638,7 +638,7 @@
|
||||||
if (transform.action === 'scale' || transform.action === 'scaleX' || transform.action === 'scaleY') {
|
if (transform.action === 'scale' || transform.action === 'scaleX' || transform.action === 'scaleY') {
|
||||||
var centerTransform = this._shouldCenterTransform(e, transform.target);
|
var centerTransform = this._shouldCenterTransform(e, transform.target);
|
||||||
|
|
||||||
// Switch from a normal resize to center-based
|
// Switch from a normal resize to center-based
|
||||||
if ((centerTransform && (transform.originX !== 'center' || transform.originY !== 'center')) ||
|
if ((centerTransform && (transform.originX !== 'center' || transform.originY !== 'center')) ||
|
||||||
// Switch from center-based resize to normal one
|
// Switch from center-based resize to normal one
|
||||||
(!centerTransform && transform.originX === 'center' && transform.originY === 'center')
|
(!centerTransform && transform.originX === 'center' && transform.originY === 'center')
|
||||||
|
|
|
||||||
|
|
@ -558,8 +558,8 @@
|
||||||
this.insertStyleObjects(_chars, isEndOfLine, useCopiedStyle);
|
this.insertStyleObjects(_chars, isEndOfLine, useCopiedStyle);
|
||||||
}
|
}
|
||||||
// else if (this.selectionEnd - this.selectionStart > 1) {
|
// else if (this.selectionEnd - this.selectionStart > 1) {
|
||||||
// TODO: replace styles properly
|
// TODO: replace styles properly
|
||||||
// console.log('replacing MORE than 1 char');
|
// console.log('replacing MORE than 1 char');
|
||||||
// }
|
// }
|
||||||
this.setSelectionStart(this.selectionStart + _chars.length);
|
this.setSelectionStart(this.selectionStart + _chars.length);
|
||||||
this.setSelectionEnd(this.selectionStart);
|
this.setSelectionEnd(this.selectionStart);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
var degreesToRadians = fabric.util.degreesToRadians,
|
var degreesToRadians = fabric.util.degreesToRadians,
|
||||||
//jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
//jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
isVML = function() { return typeof G_vmlCanvasManager !== 'undefined'; };
|
isVML = function() { return typeof G_vmlCanvasManager !== 'undefined'; };
|
||||||
//jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
//jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
||||||
|
|
||||||
fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ {
|
fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -555,10 +555,10 @@
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for caching SVG documents (loaded via `fabric.Canvas#loadSVGFromURL`)
|
* Used for caching SVG documents (loaded via `fabric.Canvas#loadSVGFromURL`)
|
||||||
* @namespace
|
* @namespace
|
||||||
*/
|
*/
|
||||||
var svgCache = {
|
var svgCache = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -821,7 +821,7 @@
|
||||||
|
|
||||||
// odd number of points is an error
|
// odd number of points is an error
|
||||||
// if (parsedPoints.length % 2 !== 0) {
|
// if (parsedPoints.length % 2 !== 0) {
|
||||||
// return null;
|
// return null;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return parsedPoints;
|
return parsedPoints;
|
||||||
|
|
|
||||||
|
|
@ -2,52 +2,52 @@
|
||||||
|
|
||||||
var clone = fabric.util.object.clone;
|
var clone = fabric.util.object.clone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IText class (introduced in <b>v1.4</b>) Events are also fired with "text:"
|
* IText class (introduced in <b>v1.4</b>) Events are also fired with "text:"
|
||||||
* prefix when observing canvas.
|
* prefix when observing canvas.
|
||||||
* @class fabric.IText
|
* @class fabric.IText
|
||||||
* @extends fabric.Text
|
* @extends fabric.Text
|
||||||
* @mixes fabric.Observable
|
* @mixes fabric.Observable
|
||||||
*
|
*
|
||||||
* @fires changed
|
* @fires changed
|
||||||
* @fires selection:changed
|
* @fires selection:changed
|
||||||
* @fires editing:entered
|
* @fires editing:entered
|
||||||
* @fires editing:exited
|
* @fires editing:exited
|
||||||
*
|
*
|
||||||
* @return {fabric.IText} thisArg
|
* @return {fabric.IText} thisArg
|
||||||
* @see {@link fabric.IText#initialize} for constructor definition
|
* @see {@link fabric.IText#initialize} for constructor definition
|
||||||
*
|
*
|
||||||
* <p>Supported key combinations:</p>
|
* <p>Supported key combinations:</p>
|
||||||
* <pre>
|
* <pre>
|
||||||
* Move cursor: left, right, up, down
|
* Move cursor: left, right, up, down
|
||||||
* Select character: shift + left, shift + right
|
* Select character: shift + left, shift + right
|
||||||
* Select text vertically: shift + up, shift + down
|
* Select text vertically: shift + up, shift + down
|
||||||
* Move cursor by word: alt + left, alt + right
|
* Move cursor by word: alt + left, alt + right
|
||||||
* Select words: shift + alt + left, shift + alt + right
|
* Select words: shift + alt + left, shift + alt + right
|
||||||
* Move cursor to line start/end: cmd + left, cmd + right or home, end
|
* Move cursor to line start/end: cmd + left, cmd + right or home, end
|
||||||
* Select till start/end of line: cmd + shift + left, cmd + shift + right or shift + home, shift + end
|
* Select till start/end of line: cmd + shift + left, cmd + shift + right or shift + home, shift + end
|
||||||
* Jump to start/end of text: cmd + up, cmd + down
|
* Jump to start/end of text: cmd + up, cmd + down
|
||||||
* Select till start/end of text: cmd + shift + up, cmd + shift + down or shift + pgUp, shift + pgDown
|
* Select till start/end of text: cmd + shift + up, cmd + shift + down or shift + pgUp, shift + pgDown
|
||||||
* Delete character: backspace
|
* Delete character: backspace
|
||||||
* Delete word: alt + backspace
|
* Delete word: alt + backspace
|
||||||
* Delete line: cmd + backspace
|
* Delete line: cmd + backspace
|
||||||
* Forward delete: delete
|
* Forward delete: delete
|
||||||
* Copy text: ctrl/cmd + c
|
* Copy text: ctrl/cmd + c
|
||||||
* Paste text: ctrl/cmd + v
|
* Paste text: ctrl/cmd + v
|
||||||
* Cut text: ctrl/cmd + x
|
* Cut text: ctrl/cmd + x
|
||||||
* Select entire text: ctrl/cmd + a
|
* Select entire text: ctrl/cmd + a
|
||||||
* Quit editing tab or esc
|
* Quit editing tab or esc
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* <p>Supported mouse/touch combination</p>
|
* <p>Supported mouse/touch combination</p>
|
||||||
* <pre>
|
* <pre>
|
||||||
* Position cursor: click/touch
|
* Position cursor: click/touch
|
||||||
* Create selection: click/touch & drag
|
* Create selection: click/touch & drag
|
||||||
* Create selection: click & shift + click
|
* Create selection: click & shift + click
|
||||||
* Select word: double click
|
* Select word: double click
|
||||||
* Select line: triple click
|
* Select line: triple click
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
fabric.IText = fabric.util.createClass(fabric.Text, fabric.Observable, /** @lends fabric.IText.prototype */ {
|
fabric.IText = fabric.util.createClass(fabric.Text, fabric.Observable, /** @lends fabric.IText.prototype */ {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -405,8 +405,8 @@
|
||||||
*/
|
*/
|
||||||
_getCursorBoundaries: function(chars, typeOfBoundaries) {
|
_getCursorBoundaries: function(chars, typeOfBoundaries) {
|
||||||
|
|
||||||
// left/top are left/top of entire text box
|
// left/top are left/top of entire text box
|
||||||
// leftOffset/topOffset are offset from that left/top point of a text box
|
// leftOffset/topOffset are offset from that left/top point of a text box
|
||||||
|
|
||||||
var left = Math.round(this._getLeftOffset()),
|
var left = Math.round(this._getLeftOffset()),
|
||||||
top = this._getTopOffset(),
|
top = this._getTopOffset(),
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes value from one to another within certain period of time, invoking callbacks as value is being changed.
|
* Changes value from one to another within certain period of time, invoking callbacks as value is being changed.
|
||||||
* @memberOf fabric.util
|
* @memberOf fabric.util
|
||||||
* @param {Object} [options] Animation options
|
* @param {Object} [options] Animation options
|
||||||
* @param {Function} [options.onChange] Callback; invoked on every value change
|
* @param {Function} [options.onChange] Callback; invoked on every value change
|
||||||
* @param {Function} [options.onComplete] Callback; invoked when value change is completed
|
* @param {Function} [options.onComplete] Callback; invoked when value change is completed
|
||||||
* @param {Number} [options.startValue=0] Starting value
|
* @param {Number} [options.startValue=0] Starting value
|
||||||
* @param {Number} [options.endValue=100] Ending value
|
* @param {Number} [options.endValue=100] Ending value
|
||||||
* @param {Number} [options.byValue=100] Value to modify the property by
|
* @param {Number} [options.byValue=100] Value to modify the property by
|
||||||
* @param {Function} [options.easing] Easing function
|
* @param {Function} [options.easing] Easing function
|
||||||
* @param {Number} [options.duration=500] Duration of change (in ms)
|
* @param {Number} [options.duration=500] Duration of change (in ms)
|
||||||
*/
|
*/
|
||||||
function animate(options) {
|
function animate(options) {
|
||||||
|
|
||||||
requestAnimFrame(function(timestamp) {
|
requestAnimFrame(function(timestamp) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue