@@ -40,6 +40,8 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
4040 /** @internal */
4141 private scrollY : number ;
4242 /** @internal */
43+ private scrolled : number ;
44+ /** @internal */
4345 private startEvent : MouseEvent ;
4446 /** @internal value saved in the same order as _originStyleProp[] */
4547 private elOriginStyleVal : string [ ] ;
@@ -156,7 +158,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
156158 private _resizeStart ( event : MouseEvent ) : DDResizable {
157159 this . originalRect = this . el . getBoundingClientRect ( ) ;
158160 const scrollEl = Utils . getScrollParent ( this . el ) ;
159- this . scrollY = scrollEl === null ? 0 : scrollEl . scrollTop ;
161+ this . scrollY = scrollEl ? scrollEl . scrollTop : 0 ;
160162 this . startEvent = event ;
161163 this . _setupHelper ( ) ;
162164 this . _applyChange ( ) ;
@@ -171,6 +173,8 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
171173
172174 /** @internal */
173175 private _resizing ( event : MouseEvent , dir : string ) : DDResizable {
176+ const scrollEl = Utils . getScrollParent ( this . el ) ;
177+ this . scrolled = scrollEl ? ( scrollEl . scrollTop - this . scrollY ) : this . scrollY ;
174178 this . temporalRect = this . _getChange ( event , dir ) ;
175179 this . _applyChange ( ) ;
176180 const ev = DDUtils . initEvent < MouseEvent > ( event , { type : 'resize' , target : this . el } ) ;
@@ -194,6 +198,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
194198 delete this . originalRect ;
195199 delete this . temporalRect ;
196200 delete this . scrollY ;
201+ delete this . scrolled ;
197202 return this ;
198203 }
199204
@@ -222,13 +227,11 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
222227 /** @internal */
223228 private _getChange ( event : MouseEvent , dir : string ) : Rect {
224229 const oEvent = this . startEvent ;
225- const scrollEl = Utils . getScrollParent ( this . el ) ;
226- const scrolled = scrollEl === null ? 0 : ( scrollEl . scrollTop - this . scrollY ) ;
227230 const newRect = { // Note: originalRect is a complex object, not a simple Rect, so copy out.
228231 width : this . originalRect . width ,
229- height : this . originalRect . height + scrolled ,
232+ height : this . originalRect . height + this . scrolled ,
230233 left : this . originalRect . left ,
231- top : this . originalRect . top - scrolled
234+ top : this . originalRect . top - this . scrolled
232235 } ;
233236
234237 const offsetH = event . clientX - oEvent . clientX ;
@@ -300,14 +303,12 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
300303
301304 /** @internal */
302305 private _ui = ( ) : DDUIData => {
303- const scrollEl = Utils . getScrollParent ( this . el ) ;
304- const scrolled = scrollEl === null ? 0 : ( scrollEl . scrollTop - this . scrollY ) ;
305306 const containmentRect = this . el . parentElement . getBoundingClientRect ( ) ;
306307 const newRect = { // Note: originalRect is a complex object, not a simple Rect, so copy out.
307308 width : this . originalRect . width ,
308- height : this . originalRect . height + scrolled ,
309+ height : this . originalRect . height + this . scrolled ,
309310 left : this . originalRect . left ,
310- top : this . originalRect . top - scrolled
311+ top : this . originalRect . top - this . scrolled
311312 } ;
312313 const rect = this . temporalRect || newRect ;
313314 return {
0 commit comments