File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed
Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -143,12 +143,30 @@ UE.plugins["fiximgclick"] = (function () {
143143 } ,
144144 updateTargetElement : function ( ) {
145145 var me = this ;
146+ // 拿到图片的原始大小
147+ var o_width = me . target . naturalWidth ;
148+ var o_height = me . target . naturalHeight ;
149+
150+ // 计算出原始图片比例
151+ var o_scale = ( o_width / o_height ) . toFixed ( 4 ) ;
152+
153+ // 再拿到图片现在的大小,可能是变形的Ï
154+ var width = parseInt ( me . resizer . style . width ) ;
155+ var height = parseInt ( me . resizer . style . height ) ;
156+
157+ // 判断改变的是宽度还是高度
158+ if ( rect [ me . dragId ] [ 2 ] != 0 ) {
159+ height = width / o_scale ;
160+ } else if ( rect [ me . dragId ] [ 3 ] != 0 ) {
161+ width = height * o_scale ;
162+ }
163+
146164 domUtils . setStyles ( me . target , {
147- width : me . resizer . style . width ,
148- height : me . resizer . style . height
165+ width : width + "px" ,
166+ height : height + "px" ,
149167 } ) ;
150- me . target . width = parseInt ( me . resizer . style . width ) ;
151- me . target . height = parseInt ( me . resizer . style . height ) ;
168+ me . target . width = width ;
169+ me . target . height = height ;
152170 me . attachTo ( me . target ) ;
153171 } ,
154172 updateContainerStyle : function ( dir , offset ) {
You can’t perform that action at this time.
0 commit comments