Skip to content

Commit c08ddd7

Browse files
SimeonCSimeonC
SimeonC
authored and
SimeonC
committed
fix(textAngular.resize): Fixes resize overlay with more than one image
Fixes #470
1 parent 2856ae5 commit c08ddd7

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/main.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ textAngular.directive("textAngular", [
9191
var _keydown, _keyup, _keypress, _mouseup, _focusin, _focusout,
9292
_originalContents, _toolbars,
9393
_serial = (attrs.serial) ? attrs.serial : Math.floor(Math.random() * 10000000000000000),
94-
_taExecCommand;
94+
_taExecCommand, _resizeMouseDown;
9595

9696
scope._name = (attrs.name) ? attrs.name : 'textAngularEditor' + _serial;
9797

@@ -232,7 +232,8 @@ textAngular.directive("textAngular", [
232232
};
233233
/* istanbul ignore next: pretty sure phantomjs won't test this */
234234
scope.showResizeOverlay = function(_el){
235-
var resizeMouseDown = function(event){
235+
var _body = $document.find('body');
236+
_resizeMouseDown = function(event){
236237
var startPosition = {
237238
width: parseInt(_el.attr('width')),
238239
height: parseInt(_el.attr('height')),
@@ -257,30 +258,33 @@ textAngular.directive("textAngular", [
257258
pos.y = ratio > newRatio ? pos.x * ratio : pos.y;
258259
}
259260
el = angular.element(_el);
261+
console.log('element', pos, _el);
260262
el.attr('height', Math.max(0, pos.y));
261263
el.attr('width', Math.max(0, pos.x));
262264

263265
// reflow the popover tooltip
264266
scope.reflowResizeOverlay(_el);
265267
};
266-
$document.find('body').on('mousemove', mousemove);
267-
oneEvent($document.find('body'), 'mouseup', function(event){
268+
_body.on('mousemove', mousemove);
269+
oneEvent(_body, 'mouseup', function(event){
268270
event.preventDefault();
269271
event.stopPropagation();
270-
$document.find('body').off('mousemove', mousemove);
272+
console.log('Trigger Removal');
273+
_body.off('mousemove', mousemove);
271274
scope.showPopover(_el);
272275
});
273276
event.stopPropagation();
274277
event.preventDefault();
275278
};
276279

277-
scope.displayElements.resize.anchors[3].on('mousedown', resizeMouseDown);
280+
scope.displayElements.resize.anchors[3].on('mousedown', _resizeMouseDown);
278281

279282
scope.reflowResizeOverlay(_el);
280-
oneEvent($document.find('body'), 'click', function(){scope.hideResizeOverlay();});
283+
oneEvent(_body, 'click', function(){scope.hideResizeOverlay();});
281284
};
282285
/* istanbul ignore next: pretty sure phantomjs won't test this */
283286
scope.hideResizeOverlay = function(){
287+
scope.displayElements.resize.anchors[3].off('mousedown', _resizeMouseDown);
284288
scope.displayElements.resize.overlay.css('display', '');
285289
};
286290

0 commit comments

Comments
 (0)