@@ -63,8 +63,6 @@ class AnnotationEditor {
6363
6464 #dragPointerType = "" ;
6565
66- #keepAspectRatio = false ;
67-
6866 #resizersDiv = null ;
6967
7068 #lastPointerCoords = null ;
@@ -736,34 +734,15 @@ class AnnotationEditor {
736734
737735 /**
738736 * Set the dimensions of this editor.
739- * @param {number } width
740- * @param {number } height
741737 */
742- setDims ( width , height ) {
743- const [ parentWidth , parentHeight ] = this . parentDimensions ;
744- const { style } = this . div ;
745- style . width = `${ ( ( 100 * width ) / parentWidth ) . toFixed ( 2 ) } %` ;
746- if ( ! this . #keepAspectRatio) {
747- style . height = `${ ( ( 100 * height ) / parentHeight ) . toFixed ( 2 ) } %` ;
748- }
749- }
750-
751- fixDims ( ) {
752- const { style } = this . div ;
753- const { height, width } = style ;
754- const widthPercent = width . endsWith ( "%" ) ;
755- const heightPercent = ! this . #keepAspectRatio && height . endsWith ( "%" ) ;
756- if ( widthPercent && heightPercent ) {
757- return ;
758- }
759-
760- const [ parentWidth , parentHeight ] = this . parentDimensions ;
761- if ( ! widthPercent ) {
762- style . width = `${ ( ( 100 * parseFloat ( width ) ) / parentWidth ) . toFixed ( 2 ) } %` ;
763- }
764- if ( ! this . #keepAspectRatio && ! heightPercent ) {
765- style . height = `${ ( ( 100 * parseFloat ( height ) ) / parentHeight ) . toFixed ( 2 ) } %` ;
766- }
738+ setDims ( ) {
739+ const {
740+ div : { style } ,
741+ width,
742+ height,
743+ } = this ;
744+ style . width = `${ ( 100 * width ) . toFixed ( 2 ) } %` ;
745+ style . height = `${ ( 100 * height ) . toFixed ( 2 ) } %` ;
767746 }
768747
769748 /**
@@ -872,8 +851,7 @@ class AnnotationEditor {
872851 this . height = height ;
873852 this . x = x ;
874853 this . y = y ;
875- const [ parentWidth , parentHeight ] = this . parentDimensions ;
876- this . setDims ( parentWidth * width , parentHeight * height ) ;
854+ this . setDims ( ) ;
877855 this . fixAndSetPosition ( ) ;
878856 this . _onResized ( ) ;
879857 }
@@ -1050,7 +1028,7 @@ class AnnotationEditor {
10501028 this . x = newX ;
10511029 this . y = newY ;
10521030
1053- this . setDims ( parentWidth * newWidth , parentHeight * newHeight ) ;
1031+ this . setDims ( ) ;
10541032 this . fixAndSetPosition ( ) ;
10551033
10561034 this . _onResizing ( ) ;
@@ -1417,7 +1395,7 @@ class AnnotationEditor {
14171395 this . width = newWidth ;
14181396 this . height = newHeight ;
14191397
1420- this . setDims ( parentWidth * newWidth , parentHeight * newHeight ) ;
1398+ this . setDims ( ) ;
14211399 this . fixAndSetPosition ( ) ;
14221400
14231401 this . _onResizing ( ) ;
@@ -2260,19 +2238,6 @@ class AnnotationEditor {
22602238 }
22612239 }
22622240
2263- /**
2264- * Set the aspect ratio to use when resizing.
2265- * @param {number } width
2266- * @param {number } height
2267- */
2268- setAspectRatio ( width , height ) {
2269- this . #keepAspectRatio = true ;
2270- const aspectRatio = width / height ;
2271- const { style } = this . div ;
2272- style . aspectRatio = aspectRatio ;
2273- style . height = "auto" ;
2274- }
2275-
22762241 static get MIN_SIZE ( ) {
22772242 return 16 ;
22782243 }
0 commit comments