88import { DDResizableHandle } from './dd-resizable-handle' ;
99import { DDBaseImplement , HTMLElementExtendOpt } from './dd-base-impl' ;
1010import { DDUtils } from './dd-utils' ;
11+ import { Utils } from '../utils' ;
1112import { DDUIData , Rect , Size } from '../types' ;
1213
1314// TODO: merge with DDDragOpt
@@ -37,6 +38,12 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
3738 /** @internal */
3839 private temporalRect : Rect ;
3940 /** @internal */
41+ private scrollY : number ;
42+ /** @internal */
43+ private scrolled : number ;
44+ /** @internal */
45+ private scrollEl : HTMLElement ;
46+ /** @internal */
4047 private startEvent : MouseEvent ;
4148 /** @internal value saved in the same order as _originStyleProp[] */
4249 private elOriginStyleVal : string [ ] ;
@@ -149,6 +156,8 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
149156 /** @internal */
150157 private _resizeStart ( event : MouseEvent ) : DDResizable {
151158 this . originalRect = this . el . getBoundingClientRect ( ) ;
159+ this . scrollEl = Utils . getScrollParent ( this . el ) ;
160+ this . scrollY = this . scrollEl . scrollTop ;
152161 this . startEvent = event ;
153162 this . _setupHelper ( ) ;
154163 this . _applyChange ( ) ;
@@ -163,6 +172,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
163172
164173 /** @internal */
165174 private _resizing ( event : MouseEvent , dir : string ) : DDResizable {
175+ this . scrolled = this . scrollEl . scrollTop - this . scrollY ;
166176 this . temporalRect = this . _getChange ( event , dir ) ;
167177 this . _applyChange ( ) ;
168178 const ev = DDUtils . initEvent < MouseEvent > ( event , { type : 'resize' , target : this . el } ) ;
@@ -185,6 +195,8 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
185195 delete this . startEvent ;
186196 delete this . originalRect ;
187197 delete this . temporalRect ;
198+ delete this . scrollY ;
199+ delete this . scrolled ;
188200 return this ;
189201 }
190202
@@ -215,10 +227,11 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
215227 const oEvent = this . startEvent ;
216228 const newRect = { // Note: originalRect is a complex object, not a simple Rect, so copy out.
217229 width : this . originalRect . width ,
218- height : this . originalRect . height ,
230+ height : this . originalRect . height + this . scrolled ,
219231 left : this . originalRect . left ,
220- top : this . originalRect . top
232+ top : this . originalRect . top - this . scrolled
221233 } ;
234+
222235 const offsetH = event . clientX - oEvent . clientX ;
223236 const offsetV = event . clientY - oEvent . clientY ;
224237
@@ -290,7 +303,13 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
290303 private _ui = ( ) : DDUIData => {
291304 const containmentEl = this . el . parentElement ;
292305 const containmentRect = containmentEl . getBoundingClientRect ( ) ;
293- const rect = this . temporalRect || this . originalRect ;
306+ const newRect = { // Note: originalRect is a complex object, not a simple Rect, so copy out.
307+ width : this . originalRect . width ,
308+ height : this . originalRect . height + this . scrolled ,
309+ left : this . originalRect . left ,
310+ top : this . originalRect . top - this . scrolled
311+ } ;
312+ const rect = this . temporalRect || newRect ;
294313 return {
295314 position : {
296315 left : rect . left - containmentRect . left ,
0 commit comments