From 97d3f5143f6438e1d6d21339b1bae0c2313585c8 Mon Sep 17 00:00:00 2001 From: Moriel Schottlender Date: Mon, 4 Nov 2013 17:05:27 -0800 Subject: [PATCH] Fix image resize handles update on surface change The resizing handles under ResizableNode are created in the location of the image but if the page is edited and the image moves relative to the document, the handles remained where the image was previously and not where its updated location is at. This code fixes that bug by changing the CE event listening to the model's 'transact' instead of 'history', and clears the cached offset when a 'transact' event happens. Change-Id: Id0e4296dd89b24839ba68a534ca77d73c23b7434 --- modules/ve/ce/ve.ce.ResizableNode.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/ve/ce/ve.ce.ResizableNode.js b/modules/ve/ce/ve.ce.ResizableNode.js index 3009cbce1f..94cba3becb 100644 --- a/modules/ve/ce/ve.ce.ResizableNode.js +++ b/modules/ve/ce/ve.ce.ResizableNode.js @@ -184,9 +184,9 @@ ve.ce.ResizableNode.prototype.onResizableLive = function () { var surfaceModel = this.getRoot().getSurface().getModel(); if ( this.live ) { - surfaceModel.connect( this, { 'history': 'setResizableHandlesSizeAndPosition' } ); + surfaceModel.getDocument().connect( this, { 'transact': 'setResizableHandlesSizeAndPosition' } ); } else { - surfaceModel.disconnect( this, { 'history': 'setResizableHandlesSizeAndPosition' } ); + surfaceModel.getDocument().disconnect( this, { 'transact': 'setResizableHandlesSizeAndPosition' } ); this.onResizableBlur(); } }; @@ -265,6 +265,9 @@ ve.ce.ResizableNode.prototype.setResizableHandlesSizeAndPosition = function () { var width = this.$resizable.width(), height = this.$resizable.height(); + // Clear cached resizable offset position as it may have changed + this.resizableOffset = null; + this.setResizableHandlesPosition(); this.$resizeHandles