fabric-rails 1.0.12 → 1.0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +16 -0
- data/README.md +1 -1
- data/lib/fabric/rails/version.rb +2 -2
- data/vendor/assets/javascripts/event.js +1909 -0
- data/vendor/assets/javascripts/fabric.js +64 -16464
- data/vendor/assets/javascripts/fabric/HEADER.js +31 -0
- data/vendor/assets/javascripts/fabric/canvas.class.js +1007 -0
- data/vendor/assets/javascripts/fabric/canvas_animation.mixin.js +113 -0
- data/vendor/assets/javascripts/fabric/canvas_events.mixin.js +482 -0
- data/vendor/assets/javascripts/fabric/canvas_gestures.mixin.js +79 -0
- data/vendor/assets/javascripts/fabric/canvas_serialization.mixin.js +311 -0
- data/vendor/assets/javascripts/fabric/circle.class.js +182 -0
- data/vendor/assets/javascripts/fabric/color.class.js +284 -0
- data/vendor/assets/javascripts/fabric/ellipse.class.js +169 -0
- data/vendor/assets/javascripts/fabric/freedrawing.class.js +256 -0
- data/vendor/assets/javascripts/fabric/gradient.class.js +211 -0
- data/vendor/assets/javascripts/fabric/group.class.js +556 -0
- data/vendor/assets/javascripts/fabric/image.class.js +418 -0
- data/vendor/assets/javascripts/fabric/image_filters.js +809 -0
- data/vendor/assets/javascripts/fabric/intersection.class.js +178 -0
- data/vendor/assets/javascripts/fabric/line.class.js +188 -0
- data/vendor/assets/javascripts/fabric/log.js +26 -0
- data/vendor/assets/javascripts/fabric/node.js +149 -0
- data/vendor/assets/javascripts/fabric/object.class.js +1068 -0
- data/vendor/assets/javascripts/fabric/object_geometry.mixin.js +308 -0
- data/vendor/assets/javascripts/fabric/object_interactivity.mixin.js +496 -0
- data/vendor/assets/javascripts/fabric/object_origin.mixin.js +207 -0
- data/vendor/assets/javascripts/fabric/object_straightening.mixin.js +94 -0
- data/vendor/assets/javascripts/fabric/observable.mixin.js +91 -0
- data/vendor/assets/javascripts/fabric/parser.js +750 -0
- data/vendor/assets/javascripts/fabric/path.class.js +794 -0
- data/vendor/assets/javascripts/fabric/path_group.class.js +240 -0
- data/vendor/assets/javascripts/fabric/pattern.class.js +69 -0
- data/vendor/assets/javascripts/fabric/point.class.js +327 -0
- data/vendor/assets/javascripts/fabric/polygon.class.js +184 -0
- data/vendor/assets/javascripts/fabric/polyline.class.js +157 -0
- data/vendor/assets/javascripts/fabric/rect.class.js +298 -0
- data/vendor/assets/javascripts/fabric/scout.js +45 -0
- data/vendor/assets/javascripts/fabric/shadow.class.js +70 -0
- data/vendor/assets/javascripts/fabric/stateful.js +88 -0
- data/vendor/assets/javascripts/fabric/static_canvas.class.js +1298 -0
- data/vendor/assets/javascripts/fabric/text.class.js +934 -0
- data/vendor/assets/javascripts/fabric/triangle.class.js +108 -0
- data/vendor/assets/javascripts/fabric/util/anim_ease.js +360 -0
- data/vendor/assets/javascripts/fabric/util/dom_event.js +237 -0
- data/vendor/assets/javascripts/fabric/util/dom_misc.js +245 -0
- data/vendor/assets/javascripts/fabric/util/dom_request.js +72 -0
- data/vendor/assets/javascripts/fabric/util/dom_style.js +71 -0
- data/vendor/assets/javascripts/fabric/util/lang_array.js +250 -0
- data/vendor/assets/javascripts/fabric/util/lang_class.js +97 -0
- data/vendor/assets/javascripts/fabric/util/lang_function.js +35 -0
- data/vendor/assets/javascripts/fabric/util/lang_object.js +34 -0
- data/vendor/assets/javascripts/fabric/util/lang_string.js +60 -0
- data/vendor/assets/javascripts/fabric/util/misc.js +406 -0
- data/vendor/assets/javascripts/json2.js +491 -0
- metadata +53 -2
@@ -0,0 +1,113 @@
|
|
1
|
+
fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.StaticCanvas.prototype */ {
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Animation duration (in ms) for fx* methods
|
5
|
+
* @type Number
|
6
|
+
*/
|
7
|
+
FX_DURATION: 500,
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Centers object horizontally with animation.
|
11
|
+
* @method fxCenterObjectH
|
12
|
+
* @param {fabric.Object} object Object to center
|
13
|
+
* @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties
|
14
|
+
* @return {fabric.Canvas} thisArg
|
15
|
+
* @chainable
|
16
|
+
*/
|
17
|
+
fxCenterObjectH: function (object, callbacks) {
|
18
|
+
callbacks = callbacks || { };
|
19
|
+
|
20
|
+
var empty = function() { },
|
21
|
+
onComplete = callbacks.onComplete || empty,
|
22
|
+
onChange = callbacks.onChange || empty,
|
23
|
+
_this = this;
|
24
|
+
|
25
|
+
fabric.util.animate({
|
26
|
+
startValue: object.get('left'),
|
27
|
+
endValue: this.getCenter().left,
|
28
|
+
duration: this.FX_DURATION,
|
29
|
+
onChange: function(value) {
|
30
|
+
object.set('left', value);
|
31
|
+
_this.renderAll();
|
32
|
+
onChange();
|
33
|
+
},
|
34
|
+
onComplete: function() {
|
35
|
+
object.setCoords();
|
36
|
+
onComplete();
|
37
|
+
}
|
38
|
+
});
|
39
|
+
|
40
|
+
return this;
|
41
|
+
},
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Centers object vertically with animation.
|
45
|
+
* @method fxCenterObjectV
|
46
|
+
* @param {fabric.Object} object Object to center
|
47
|
+
* @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties
|
48
|
+
* @return {fabric.Canvas} thisArg
|
49
|
+
* @chainable
|
50
|
+
*/
|
51
|
+
fxCenterObjectV: function (object, callbacks) {
|
52
|
+
callbacks = callbacks || { };
|
53
|
+
|
54
|
+
var empty = function() { },
|
55
|
+
onComplete = callbacks.onComplete || empty,
|
56
|
+
onChange = callbacks.onChange || empty,
|
57
|
+
_this = this;
|
58
|
+
|
59
|
+
fabric.util.animate({
|
60
|
+
startValue: object.get('top'),
|
61
|
+
endValue: this.getCenter().top,
|
62
|
+
duration: this.FX_DURATION,
|
63
|
+
onChange: function(value) {
|
64
|
+
object.set('top', value);
|
65
|
+
_this.renderAll();
|
66
|
+
onChange();
|
67
|
+
},
|
68
|
+
onComplete: function() {
|
69
|
+
object.setCoords();
|
70
|
+
onComplete();
|
71
|
+
}
|
72
|
+
});
|
73
|
+
|
74
|
+
return this;
|
75
|
+
},
|
76
|
+
|
77
|
+
/**
|
78
|
+
* Same as `fabric.Canvas#remove` but animated
|
79
|
+
* @method fxRemove
|
80
|
+
* @param {fabric.Object} object Object to remove
|
81
|
+
* @param {Function} callback Callback, invoked on effect completion
|
82
|
+
* @return {fabric.Canvas} thisArg
|
83
|
+
* @chainable
|
84
|
+
*/
|
85
|
+
fxRemove: function (object, callbacks) {
|
86
|
+
callbacks = callbacks || { };
|
87
|
+
|
88
|
+
var empty = function() { },
|
89
|
+
onComplete = callbacks.onComplete || empty,
|
90
|
+
onChange = callbacks.onChange || empty,
|
91
|
+
_this = this;
|
92
|
+
|
93
|
+
fabric.util.animate({
|
94
|
+
startValue: object.get('opacity'),
|
95
|
+
endValue: 0,
|
96
|
+
duration: this.FX_DURATION,
|
97
|
+
onStart: function() {
|
98
|
+
object.setActive(false);
|
99
|
+
},
|
100
|
+
onChange: function(value) {
|
101
|
+
object.set('opacity', value);
|
102
|
+
_this.renderAll();
|
103
|
+
onChange();
|
104
|
+
},
|
105
|
+
onComplete: function () {
|
106
|
+
_this.remove(object);
|
107
|
+
onComplete();
|
108
|
+
}
|
109
|
+
});
|
110
|
+
|
111
|
+
return this;
|
112
|
+
}
|
113
|
+
});
|
@@ -0,0 +1,482 @@
|
|
1
|
+
(function(){
|
2
|
+
|
3
|
+
var cursorMap = {
|
4
|
+
'tr': 'ne-resize',
|
5
|
+
'br': 'se-resize',
|
6
|
+
'bl': 'sw-resize',
|
7
|
+
'tl': 'nw-resize',
|
8
|
+
'ml': 'w-resize',
|
9
|
+
'mt': 'n-resize',
|
10
|
+
'mr': 'e-resize',
|
11
|
+
'mb': 's-resize'
|
12
|
+
},
|
13
|
+
addListener = fabric.util.addListener,
|
14
|
+
removeListener = fabric.util.removeListener,
|
15
|
+
getPointer = fabric.util.getPointer;
|
16
|
+
|
17
|
+
fabric.util.object.extend(fabric.Canvas.prototype, /** @scope fabric.Canvas.prototype */ {
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Adds mouse listeners to canvas
|
21
|
+
* @method _initEvents
|
22
|
+
* @private
|
23
|
+
* See configuration documentation for more details.
|
24
|
+
*/
|
25
|
+
_initEvents: function () {
|
26
|
+
var _this = this;
|
27
|
+
|
28
|
+
this._onMouseDown = this._onMouseDown.bind(this);
|
29
|
+
this._onMouseMove = this._onMouseMove.bind(this);
|
30
|
+
this._onMouseUp = this._onMouseUp.bind(this);
|
31
|
+
this._onResize = this._onResize.bind(this);
|
32
|
+
|
33
|
+
addListener(fabric.window, 'resize', this._onResize);
|
34
|
+
|
35
|
+
if (fabric.isTouchSupported) {
|
36
|
+
addListener(this.upperCanvasEl, 'touchstart', this._onMouseDown);
|
37
|
+
addListener(this.upperCanvasEl, 'touchmove', this._onMouseMove);
|
38
|
+
|
39
|
+
if (typeof Event !== 'undefined' && 'add' in Event) {
|
40
|
+
Event.add(this.upperCanvasEl, 'gesture', function(e, s) {
|
41
|
+
_this.__onTransformGesture(e, s);
|
42
|
+
});
|
43
|
+
}
|
44
|
+
}
|
45
|
+
else {
|
46
|
+
addListener(this.upperCanvasEl, 'mousedown', this._onMouseDown);
|
47
|
+
addListener(this.upperCanvasEl, 'mousemove', this._onMouseMove);
|
48
|
+
}
|
49
|
+
},
|
50
|
+
|
51
|
+
/**
|
52
|
+
* @method _onMouseDown
|
53
|
+
* @private
|
54
|
+
*/
|
55
|
+
_onMouseDown: function (e) {
|
56
|
+
this.__onMouseDown(e);
|
57
|
+
|
58
|
+
!fabric.isTouchSupported && addListener(fabric.document, 'mouseup', this._onMouseUp);
|
59
|
+
fabric.isTouchSupported && addListener(fabric.document, 'touchend', this._onMouseUp);
|
60
|
+
|
61
|
+
!fabric.isTouchSupported && addListener(fabric.document, 'mousemove', this._onMouseMove);
|
62
|
+
fabric.isTouchSupported && addListener(fabric.document, 'touchmove', this._onMouseMove);
|
63
|
+
|
64
|
+
!fabric.isTouchSupported && removeListener(this.upperCanvasEl, 'mousemove', this._onMouseMove);
|
65
|
+
fabric.isTouchSupported && removeListener(this.upperCanvasEl, 'touchmove', this._onMouseMove);
|
66
|
+
},
|
67
|
+
|
68
|
+
/**
|
69
|
+
* @method _onMouseUp
|
70
|
+
* @private
|
71
|
+
*/
|
72
|
+
_onMouseUp: function (e) {
|
73
|
+
this.__onMouseUp(e);
|
74
|
+
|
75
|
+
!fabric.isTouchSupported && removeListener(fabric.document, 'mouseup', this._onMouseUp);
|
76
|
+
fabric.isTouchSupported && removeListener(fabric.document, 'touchend', this._onMouseUp);
|
77
|
+
|
78
|
+
!fabric.isTouchSupported && removeListener(fabric.document, 'mousemove', this._onMouseMove);
|
79
|
+
fabric.isTouchSupported && removeListener(fabric.document, 'touchmove', this._onMouseMove);
|
80
|
+
|
81
|
+
!fabric.isTouchSupported && addListener(this.upperCanvasEl, 'mousemove', this._onMouseMove);
|
82
|
+
fabric.isTouchSupported && addListener(this.upperCanvasEl, 'touchmove', this._onMouseMove);
|
83
|
+
},
|
84
|
+
|
85
|
+
/**
|
86
|
+
* @method _onMouseMove
|
87
|
+
* @private
|
88
|
+
*/
|
89
|
+
_onMouseMove: function (e) {
|
90
|
+
e.preventDefault && e.preventDefault();
|
91
|
+
this.__onMouseMove(e);
|
92
|
+
},
|
93
|
+
|
94
|
+
/**
|
95
|
+
* @method _onResize
|
96
|
+
* @private
|
97
|
+
*/
|
98
|
+
_onResize: function () {
|
99
|
+
this.calcOffset();
|
100
|
+
},
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Method that defines the actions when mouse is released on canvas.
|
104
|
+
* The method resets the currentTransform parameters, store the image corner
|
105
|
+
* position in the image object and render the canvas on top.
|
106
|
+
* @method __onMouseUp
|
107
|
+
* @param {Event} e Event object fired on mouseup
|
108
|
+
*
|
109
|
+
*/
|
110
|
+
__onMouseUp: function (e) {
|
111
|
+
|
112
|
+
var target;
|
113
|
+
|
114
|
+
if (this.isDrawingMode && this._isCurrentlyDrawing) {
|
115
|
+
this.freeDrawing._finalizeAndAddPath();
|
116
|
+
this.fire('mouse:up', { e: e });
|
117
|
+
return;
|
118
|
+
}
|
119
|
+
|
120
|
+
if (this._currentTransform) {
|
121
|
+
|
122
|
+
var transform = this._currentTransform;
|
123
|
+
|
124
|
+
target = transform.target;
|
125
|
+
if (target._scaling) {
|
126
|
+
target._scaling = false;
|
127
|
+
}
|
128
|
+
|
129
|
+
// determine the new coords everytime the image changes its position
|
130
|
+
var i = this._objects.length;
|
131
|
+
while (i--) {
|
132
|
+
this._objects[i].setCoords();
|
133
|
+
}
|
134
|
+
|
135
|
+
target.isMoving = false;
|
136
|
+
|
137
|
+
// only fire :modified event if target coordinates were changed during mousedown-mouseup
|
138
|
+
if (this.stateful && target.hasStateChanged()) {
|
139
|
+
this.fire('object:modified', { target: target });
|
140
|
+
target.fire('modified');
|
141
|
+
}
|
142
|
+
|
143
|
+
if (this._previousOriginX) {
|
144
|
+
this._currentTransform.target.adjustPosition(this._previousOriginX);
|
145
|
+
this._previousOriginX = null;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
this._currentTransform = null;
|
150
|
+
|
151
|
+
if (this._groupSelector) {
|
152
|
+
// group selection was completed, determine its bounds
|
153
|
+
this._findSelectedObjects(e);
|
154
|
+
}
|
155
|
+
var activeGroup = this.getActiveGroup();
|
156
|
+
if (activeGroup) {
|
157
|
+
activeGroup.setObjectsCoords();
|
158
|
+
activeGroup.set('isMoving', false);
|
159
|
+
this._setCursor(this.defaultCursor);
|
160
|
+
}
|
161
|
+
|
162
|
+
// clear selection
|
163
|
+
this._groupSelector = null;
|
164
|
+
this.renderAll();
|
165
|
+
|
166
|
+
this._setCursorFromEvent(e, target);
|
167
|
+
|
168
|
+
// fix for FF
|
169
|
+
this._setCursor('');
|
170
|
+
|
171
|
+
var _this = this;
|
172
|
+
setTimeout(function () {
|
173
|
+
_this._setCursorFromEvent(e, target);
|
174
|
+
}, 50);
|
175
|
+
|
176
|
+
this.fire('mouse:up', { target: target, e: e });
|
177
|
+
target && target.fire('mouseup', { e: e });
|
178
|
+
},
|
179
|
+
|
180
|
+
/**
|
181
|
+
* Method that defines the actions when mouse is clic ked on canvas.
|
182
|
+
* The method inits the currentTransform parameters and renders all the
|
183
|
+
* canvas so the current image can be placed on the top canvas and the rest
|
184
|
+
* in on the container one.
|
185
|
+
* @method __onMouseDown
|
186
|
+
* @param e {Event} Event object fired on mousedown
|
187
|
+
*
|
188
|
+
*/
|
189
|
+
__onMouseDown: function (e) {
|
190
|
+
|
191
|
+
var pointer;
|
192
|
+
|
193
|
+
// accept only left clicks
|
194
|
+
var isLeftClick = 'which' in e ? e.which === 1 : e.button === 1;
|
195
|
+
if (!isLeftClick && !fabric.isTouchSupported) return;
|
196
|
+
|
197
|
+
if (this.isDrawingMode) {
|
198
|
+
pointer = this.getPointer(e);
|
199
|
+
this.freeDrawing._prepareForDrawing(pointer);
|
200
|
+
|
201
|
+
// capture coordinates immediately;
|
202
|
+
// this allows to draw dots (when movement never occurs)
|
203
|
+
this.freeDrawing._captureDrawingPath(pointer);
|
204
|
+
|
205
|
+
this.fire('mouse:down', { e: e });
|
206
|
+
return;
|
207
|
+
}
|
208
|
+
|
209
|
+
// ignore if some object is being transformed at this moment
|
210
|
+
if (this._currentTransform) return;
|
211
|
+
|
212
|
+
var target = this.findTarget(e), corner;
|
213
|
+
pointer = this.getPointer(e);
|
214
|
+
|
215
|
+
if (this._shouldClearSelection(e)) {
|
216
|
+
this._groupSelector = {
|
217
|
+
ex: pointer.x,
|
218
|
+
ey: pointer.y,
|
219
|
+
top: 0,
|
220
|
+
left: 0
|
221
|
+
};
|
222
|
+
this.deactivateAllWithDispatch();
|
223
|
+
}
|
224
|
+
else {
|
225
|
+
// determine if it's a drag or rotate case
|
226
|
+
this.stateful && target.saveState();
|
227
|
+
|
228
|
+
if ((corner = target._findTargetCorner(e, this._offset))) {
|
229
|
+
this.onBeforeScaleRotate(target);
|
230
|
+
}
|
231
|
+
|
232
|
+
if (this._shouldHandleGroupLogic(e, target)) {
|
233
|
+
this._handleGroupLogic(e, target);
|
234
|
+
target = this.getActiveGroup();
|
235
|
+
}
|
236
|
+
else {
|
237
|
+
if (target !== this.getActiveGroup()) {
|
238
|
+
this.deactivateAll();
|
239
|
+
}
|
240
|
+
this.setActiveObject(target, e);
|
241
|
+
}
|
242
|
+
|
243
|
+
this._setupCurrentTransform(e, target);
|
244
|
+
}
|
245
|
+
// we must renderAll so that active image is placed on the top canvas
|
246
|
+
this.renderAll();
|
247
|
+
|
248
|
+
this.fire('mouse:down', { target: target, e: e });
|
249
|
+
target && target.fire('mousedown', { e: e });
|
250
|
+
|
251
|
+
// center origin when rotating
|
252
|
+
if (corner === 'mtr') {
|
253
|
+
this._previousOriginX = this._currentTransform.target.originX;
|
254
|
+
this._currentTransform.target.adjustPosition('center');
|
255
|
+
this._currentTransform.left = this._currentTransform.target.left;
|
256
|
+
this._currentTransform.top = this._currentTransform.target.top;
|
257
|
+
}
|
258
|
+
},
|
259
|
+
|
260
|
+
/**
|
261
|
+
* Method that defines the actions when mouse is hovering the canvas.
|
262
|
+
* The currentTransform parameter will definde whether the user is rotating/scaling/translating
|
263
|
+
* an image or neither of them (only hovering). A group selection is also possible and would cancel
|
264
|
+
* all any other type of action.
|
265
|
+
* In case of an image transformation only the top canvas will be rendered.
|
266
|
+
* @method __onMouseMove
|
267
|
+
* @param e {Event} Event object fired on mousemove
|
268
|
+
*
|
269
|
+
*/
|
270
|
+
__onMouseMove: function (e) {
|
271
|
+
|
272
|
+
var target, pointer;
|
273
|
+
|
274
|
+
if (this.isDrawingMode) {
|
275
|
+
if (this._isCurrentlyDrawing) {
|
276
|
+
pointer = this.getPointer(e);
|
277
|
+
this.freeDrawing._captureDrawingPath(pointer);
|
278
|
+
|
279
|
+
// redraw curve
|
280
|
+
// clear top canvas
|
281
|
+
this.clearContext(this.contextTop);
|
282
|
+
this.freeDrawing._render(this.contextTop);
|
283
|
+
}
|
284
|
+
this.upperCanvasEl.style.cursor = this.freeDrawingCursor;
|
285
|
+
this.fire('mouse:move', { e: e });
|
286
|
+
return;
|
287
|
+
}
|
288
|
+
|
289
|
+
var groupSelector = this._groupSelector;
|
290
|
+
|
291
|
+
// We initially clicked in an empty area, so we draw a box for multiple selection.
|
292
|
+
if (groupSelector !== null) {
|
293
|
+
pointer = getPointer(e, this.upperCanvasEl);
|
294
|
+
|
295
|
+
groupSelector.left = pointer.x - this._offset.left - groupSelector.ex;
|
296
|
+
groupSelector.top = pointer.y - this._offset.top - groupSelector.ey;
|
297
|
+
this.renderTop();
|
298
|
+
}
|
299
|
+
else if (!this._currentTransform) {
|
300
|
+
|
301
|
+
// alias style to elimintate unnecessary lookup
|
302
|
+
var style = this.upperCanvasEl.style;
|
303
|
+
|
304
|
+
// Here we are hovering the canvas then we will determine
|
305
|
+
// what part of the pictures we are hovering to change the caret symbol.
|
306
|
+
// We won't do that while dragging or rotating in order to improve the
|
307
|
+
// performance.
|
308
|
+
target = this.findTarget(e);
|
309
|
+
|
310
|
+
if (!target) {
|
311
|
+
// image/text was hovered-out from, we remove its borders
|
312
|
+
for (var i = this._objects.length; i--; ) {
|
313
|
+
if (this._objects[i] && !this._objects[i].active) {
|
314
|
+
this._objects[i].setActive(false);
|
315
|
+
}
|
316
|
+
}
|
317
|
+
style.cursor = this.defaultCursor;
|
318
|
+
}
|
319
|
+
else {
|
320
|
+
// set proper cursor
|
321
|
+
this._setCursorFromEvent(e, target);
|
322
|
+
}
|
323
|
+
}
|
324
|
+
else {
|
325
|
+
// object is being transformed (scaled/rotated/moved/etc.)
|
326
|
+
pointer = getPointer(e, this.upperCanvasEl);
|
327
|
+
|
328
|
+
var x = pointer.x,
|
329
|
+
y = pointer.y;
|
330
|
+
|
331
|
+
this._currentTransform.target.isMoving = true;
|
332
|
+
|
333
|
+
var t = this._currentTransform, reset = false;
|
334
|
+
if (
|
335
|
+
(t.action === 'scale' || t.action === 'scaleX' || t.action === 'scaleY')
|
336
|
+
&&
|
337
|
+
(
|
338
|
+
// Switch from a normal resize to center-based
|
339
|
+
(e.altKey && (t.originX !== 'center' || t.originY !== 'center'))
|
340
|
+
||
|
341
|
+
// Switch from center-based resize to normal one
|
342
|
+
(!e.altKey && t.originX === 'center' && t.originY === 'center')
|
343
|
+
)
|
344
|
+
) {
|
345
|
+
this._resetCurrentTransform(e);
|
346
|
+
reset = true;
|
347
|
+
}
|
348
|
+
|
349
|
+
if (this._currentTransform.action === 'rotate') {
|
350
|
+
this._rotateObject(x, y);
|
351
|
+
|
352
|
+
this.fire('object:rotating', {
|
353
|
+
target: this._currentTransform.target,
|
354
|
+
e: e
|
355
|
+
});
|
356
|
+
this._currentTransform.target.fire('rotating');
|
357
|
+
}
|
358
|
+
else if (this._currentTransform.action === 'scale') {
|
359
|
+
// rotate object only if shift key is not pressed
|
360
|
+
// and if it is not a group we are transforming
|
361
|
+
|
362
|
+
// TODO
|
363
|
+
/*if (!e.shiftKey) {
|
364
|
+
this._rotateObject(x, y);
|
365
|
+
|
366
|
+
this.fire('object:rotating', {
|
367
|
+
target: this._currentTransform.target,
|
368
|
+
e: e
|
369
|
+
});
|
370
|
+
this._currentTransform.target.fire('rotating');
|
371
|
+
}*/
|
372
|
+
|
373
|
+
// if (!this._currentTransform.target.hasRotatingPoint) {
|
374
|
+
// this._scaleObject(x, y);
|
375
|
+
// this.fire('object:scaling', {
|
376
|
+
// target: this._currentTransform.target
|
377
|
+
// });
|
378
|
+
// this._currentTransform.target.fire('scaling');
|
379
|
+
// }
|
380
|
+
|
381
|
+
if (e.shiftKey || this.uniScaleTransform) {
|
382
|
+
this._currentTransform.currentAction = 'scale';
|
383
|
+
this._scaleObject(x, y);
|
384
|
+
}
|
385
|
+
else {
|
386
|
+
if (!reset && t.currentAction === 'scale') {
|
387
|
+
// Switch from a normal resize to proportional
|
388
|
+
this._resetCurrentTransform(e);
|
389
|
+
}
|
390
|
+
|
391
|
+
this._currentTransform.currentAction = 'scaleEqually';
|
392
|
+
this._scaleObject(x, y, 'equally');
|
393
|
+
}
|
394
|
+
|
395
|
+
this.fire('object:scaling', {
|
396
|
+
target: this._currentTransform.target,
|
397
|
+
e: e
|
398
|
+
});
|
399
|
+
}
|
400
|
+
// else if (this._currentTransform.action === 'scale') {
|
401
|
+
// this._scaleObject(x, y);
|
402
|
+
// this.fire('object:scaling', {
|
403
|
+
// target: this._currentTransform.target
|
404
|
+
// });
|
405
|
+
// this._currentTransform.target.fire('scaling');
|
406
|
+
// }
|
407
|
+
else if (this._currentTransform.action === 'scaleX') {
|
408
|
+
this._scaleObject(x, y, 'x');
|
409
|
+
|
410
|
+
this.fire('object:scaling', {
|
411
|
+
target: this._currentTransform.target,
|
412
|
+
e: e
|
413
|
+
});
|
414
|
+
this._currentTransform.target.fire('scaling', { e: e });
|
415
|
+
}
|
416
|
+
else if (this._currentTransform.action === 'scaleY') {
|
417
|
+
this._scaleObject(x, y, 'y');
|
418
|
+
|
419
|
+
this.fire('object:scaling', {
|
420
|
+
target: this._currentTransform.target,
|
421
|
+
e: e
|
422
|
+
});
|
423
|
+
this._currentTransform.target.fire('scaling', { e: e });
|
424
|
+
}
|
425
|
+
else {
|
426
|
+
this._translateObject(x, y);
|
427
|
+
|
428
|
+
this.fire('object:moving', {
|
429
|
+
target: this._currentTransform.target,
|
430
|
+
e: e
|
431
|
+
});
|
432
|
+
|
433
|
+
this._setCursor(this.moveCursor);
|
434
|
+
|
435
|
+
this._currentTransform.target.fire('moving', { e: e });
|
436
|
+
}
|
437
|
+
// only commit here. when we are actually moving the pictures
|
438
|
+
this.renderAll();
|
439
|
+
}
|
440
|
+
this.fire('mouse:move', { target: target, e: e });
|
441
|
+
target && target.fire('mousemove', { e: e });
|
442
|
+
},
|
443
|
+
/**
|
444
|
+
* Sets the cursor depending on where the canvas is being hovered.
|
445
|
+
* Note: very buggy in Opera
|
446
|
+
* @method _setCursorFromEvent
|
447
|
+
* @param e {Event} Event object
|
448
|
+
* @param target {Object} Object that the mouse is hovering, if so.
|
449
|
+
*/
|
450
|
+
_setCursorFromEvent: function (e, target) {
|
451
|
+
var s = this.upperCanvasEl.style;
|
452
|
+
if (!target) {
|
453
|
+
s.cursor = this.defaultCursor;
|
454
|
+
return false;
|
455
|
+
}
|
456
|
+
else {
|
457
|
+
var activeGroup = this.getActiveGroup();
|
458
|
+
// only show proper corner when group selection is not active
|
459
|
+
var corner = target._findTargetCorner
|
460
|
+
&& (!activeGroup || !activeGroup.contains(target))
|
461
|
+
&& target._findTargetCorner(e, this._offset);
|
462
|
+
|
463
|
+
if (!corner) {
|
464
|
+
s.cursor = this.hoverCursor;
|
465
|
+
}
|
466
|
+
else {
|
467
|
+
if (corner in cursorMap) {
|
468
|
+
s.cursor = cursorMap[corner];
|
469
|
+
}
|
470
|
+
else if (corner === 'mtr' && target.hasRotatingPoint) {
|
471
|
+
s.cursor = this.rotationCursor;
|
472
|
+
}
|
473
|
+
else {
|
474
|
+
s.cursor = this.defaultCursor;
|
475
|
+
return false;
|
476
|
+
}
|
477
|
+
}
|
478
|
+
}
|
479
|
+
return true;
|
480
|
+
}
|
481
|
+
});
|
482
|
+
})();
|