mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-20 22:20:59 +00:00
Make setCursor public.
JSCS tweaks.
This commit is contained in:
parent
4e64cf499a
commit
de99a508c2
3 changed files with 42 additions and 20 deletions
|
|
@ -339,7 +339,9 @@
|
|||
* @param {fabric.Object} target
|
||||
*/
|
||||
_shouldCenterTransform: function (e, target) {
|
||||
if (!target) return;
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
|
||||
var t = this._currentTransform,
|
||||
centerTransform;
|
||||
|
|
@ -403,7 +405,9 @@
|
|||
* @param {fabric.Object} target
|
||||
*/
|
||||
_setupCurrentTransform: function (e, target) {
|
||||
if (!target) return;
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
|
||||
var pointer = this.getPointer(e),
|
||||
corner = target._findTargetCorner(this.getPointer(e, true)),
|
||||
|
|
@ -472,7 +476,9 @@
|
|||
lockScalingX = target.get('lockScalingX'),
|
||||
lockScalingY = target.get('lockScalingY');
|
||||
|
||||
if (lockScalingX && lockScalingY) return;
|
||||
if (lockScalingX && lockScalingY) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the constraint point
|
||||
var constraintPosition = target.translateToOriginPoint(target.getCenterPoint(), t.originX, t.originY),
|
||||
|
|
@ -616,14 +622,16 @@
|
|||
/**
|
||||
* Rotates object by invoking its rotate method
|
||||
* @private
|
||||
* @param x {Number} pointer's x coordinate
|
||||
* @param y {Number} pointer's y coordinate
|
||||
* @param {Number} x pointer's x coordinate
|
||||
* @param {Number} y pointer's y coordinate
|
||||
*/
|
||||
_rotateObject: function (x, y) {
|
||||
|
||||
var t = this._currentTransform;
|
||||
|
||||
if (t.target.get('lockRotation')) return;
|
||||
if (t.target.get('lockRotation')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var lastAngle = atan2(t.ey - t.top, t.ex - t.left),
|
||||
curAngle = atan2(y - t.top, x - t.left),
|
||||
|
|
@ -638,9 +646,11 @@
|
|||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Set the cursor type of the canvas element
|
||||
* @param {String} value Cursor type of the canvas element.
|
||||
* @see http://www.w3.org/TR/css3-ui/#cursor
|
||||
*/
|
||||
_setCursor: function (value) {
|
||||
setCursor: function (value) {
|
||||
this.upperCanvasEl.style.cursor = value;
|
||||
},
|
||||
|
||||
|
|
@ -720,7 +730,9 @@
|
|||
* @param {Boolean} skipGroup when true, group is skipped and only objects are traversed through
|
||||
*/
|
||||
findTarget: function (e, skipGroup) {
|
||||
if (this.skipTargetFind) return;
|
||||
if (this.skipTargetFind) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._isLastRenderedObject(e)) {
|
||||
return this.lastRenderedObjectWithControlsAboveOverlay;
|
||||
|
|
@ -1100,7 +1112,9 @@
|
|||
*/
|
||||
_drawObjectsControls: function(ctx) {
|
||||
for (var i = 0, len = this._objects.length; i < len; ++i) {
|
||||
if (!this._objects[i] || !this._objects[i].active) continue;
|
||||
if (!this._objects[i] || !this._objects[i].active) {
|
||||
continue;
|
||||
}
|
||||
this._objects[i]._renderControls(ctx);
|
||||
this.lastRenderedObjectWithControlsAboveOverlay = this._objects[i];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -334,8 +334,8 @@
|
|||
if (this.clipTo) {
|
||||
fabric.util.clipContext(this, this.contextTop);
|
||||
}
|
||||
var ivt = fabric.util.invertTransform(this.viewportTransform);
|
||||
var pointer = fabric.util.transformPoint(this.getPointer(e, true), ivt);
|
||||
var ivt = fabric.util.invertTransform(this.viewportTransform),
|
||||
pointer = fabric.util.transformPoint(this.getPointer(e, true), ivt);
|
||||
this.freeDrawingBrush.onMouseDown(pointer);
|
||||
this.fire('mouse:down', { e: e });
|
||||
},
|
||||
|
|
@ -350,7 +350,7 @@
|
|||
pointer = fabric.util.transformPoint(this.getPointer(e, true), ivt);
|
||||
this.freeDrawingBrush.onMouseMove(pointer);
|
||||
}
|
||||
this.upperCanvasEl.style.cursor = this.freeDrawingCursor;
|
||||
this.setCursor(this.freeDrawingCursor);
|
||||
this.fire('mouse:move', { e: e });
|
||||
},
|
||||
|
||||
|
|
@ -379,7 +379,9 @@
|
|||
|
||||
// accept only left clicks
|
||||
var isLeftClick = 'which' in e ? e.which === 1 : e.button === 1;
|
||||
if (!isLeftClick && !fabric.isTouchSupported) return;
|
||||
if (!isLeftClick && !fabric.isTouchSupported) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isDrawingMode) {
|
||||
this._onMouseDownInDrawingMode(e);
|
||||
|
|
@ -387,7 +389,9 @@
|
|||
}
|
||||
|
||||
// ignore if some object is being transformed at this moment
|
||||
if (this._currentTransform) return;
|
||||
if (this._currentTransform) {
|
||||
return;
|
||||
}
|
||||
|
||||
var target = this.findTarget(e),
|
||||
pointer = this.getPointer(e, true);
|
||||
|
|
@ -529,7 +533,7 @@
|
|||
target = this.findTarget(e);
|
||||
|
||||
if (!target || target && !target.selectable) {
|
||||
this.upperCanvasEl.style.cursor = this.defaultCursor;
|
||||
this.setCursor(this.defaultCursor);
|
||||
}
|
||||
else {
|
||||
this._setCursorFromEvent(e, target);
|
||||
|
|
@ -588,7 +592,7 @@
|
|||
else {
|
||||
this._translateObject(x, y);
|
||||
this._fire('moving', target, e);
|
||||
this._setCursor(this.moveCursor);
|
||||
this.setCursor(this.moveCursor);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -156,7 +156,9 @@
|
|||
for (var i = this._objects.length; i--; ) {
|
||||
currentObject = this._objects[i];
|
||||
|
||||
if (!currentObject || !currentObject.selectable || !currentObject.visible) continue;
|
||||
if (!currentObject || !currentObject.selectable || !currentObject.visible) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (currentObject.intersectsWithRect(selectionX1Y1, selectionX2Y2) ||
|
||||
currentObject.isContainedWithinRect(selectionX1Y1, selectionX2Y2) ||
|
||||
|
|
@ -167,7 +169,9 @@
|
|||
group.push(currentObject);
|
||||
|
||||
// only add one object if it's a click
|
||||
if (isClick) break;
|
||||
if (isClick) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -186,7 +190,7 @@
|
|||
if (activeGroup) {
|
||||
activeGroup.setObjectsCoords().setCoords();
|
||||
activeGroup.isMoving = false;
|
||||
this._setCursor(this.defaultCursor);
|
||||
this.setCursor(this.defaultCursor);
|
||||
}
|
||||
|
||||
// clear selection and current transformation
|
||||
|
|
|
|||
Loading…
Reference in a new issue