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
This commit is contained in:
Moriel Schottlender 2013-11-04 17:05:27 -08:00 committed by Roan Kattouw
parent 3469c01488
commit 97d3f5143f

View file

@ -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