8
0
Просмотр исходного кода

Internal: Fixed an issue where center-aligned image would not be properly shrinked.

It was mispositioned relative to the cursor.
Marek Lewandowski 6 лет назад
Родитель
Сommit
7137add8fc

+ 15 - 10
packages/ckeditor5-widget/src/resizertopbound.js

@@ -29,23 +29,26 @@ export default class ResizerCentral {
 	attach() {}
 
 	begin() {
-		this.redraw();
+		const clientRect = this.context._getResizeHost().getBoundingClientRect();
+
+		// Size of resize host before current resizing transaction.
+		this.initialSize = {
+			width: clientRect.width,
+			height: clientRect.height
+		};
+
+		this.redrawShadow();
+
 		const resizeHost = this.context._getResizeHost();
 		this.closestReferencePoint = getAbsoluteBoundaryPoint( resizeHost, this.context.referenceHandlerPosition );
 	}
 
-	redraw() {
+	redrawShadow() {
 		if ( this.context.domResizeWrapper ) {
 			const clientRect = this.context._getResizeHost().getBoundingClientRect();
 
-			// Size of resize host before current resizing transaction.
-			this.initialSize = {
-				width: clientRect.width,
-				height: clientRect.height
-			};
-
-			this.context.domResizeWrapper.style.width = this.initialSize.width + 'px';
-			this.context.domResizeWrapper.style.height = this.initialSize.height + 'px';
+			this.context.domResizeWrapper.style.width = clientRect.width + 'px';
+			this.context.domResizeWrapper.style.height = clientRect.height + 'px';
 		}
 	}
 
@@ -138,6 +141,8 @@ export default class ResizerCentral {
 
 		return drawnSize; // @todo decide what size should actually be returned.
 	}
+
+	redraw() {}
 }
 
 mix( ResizerCentral, ObservableMixin );

+ 1 - 1
packages/ckeditor5-widget/src/widgetresizer.js

@@ -74,7 +74,7 @@ export default class WidgetResizer extends Plugin {
 			for ( const context of this.contexts ) {
 				// This check is needed, as there were cases when widget was not yet initialized but layoutChanged happened.
 				if ( context.domResizeWrapper && context.domResizeWrapper.parentElement ) {
-					context.resizeStrategy.redraw();
+					context.resizeStrategy.redrawShadow();
 				}
 			}
 		} );