@@ -40,6 +40,8 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
40
40
/** @internal */
41
41
private scrollY : number ;
42
42
/** @internal */
43
+ private scrolled : number ;
44
+ /** @internal */
43
45
private startEvent : MouseEvent ;
44
46
/** @internal value saved in the same order as _originStyleProp[] */
45
47
private elOriginStyleVal : string [ ] ;
@@ -156,7 +158,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
156
158
private _resizeStart ( event : MouseEvent ) : DDResizable {
157
159
this . originalRect = this . el . getBoundingClientRect ( ) ;
158
160
const scrollEl = Utils . getScrollParent ( this . el ) ;
159
- this . scrollY = scrollEl === null ? 0 : scrollEl . scrollTop ;
161
+ this . scrollY = scrollEl ? scrollEl . scrollTop : 0 ;
160
162
this . startEvent = event ;
161
163
this . _setupHelper ( ) ;
162
164
this . _applyChange ( ) ;
@@ -171,6 +173,8 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
171
173
172
174
/** @internal */
173
175
private _resizing ( event : MouseEvent , dir : string ) : DDResizable {
176
+ const scrollEl = Utils . getScrollParent ( this . el ) ;
177
+ this . scrolled = scrollEl ? ( scrollEl . scrollTop - this . scrollY ) : this . scrollY ;
174
178
this . temporalRect = this . _getChange ( event , dir ) ;
175
179
this . _applyChange ( ) ;
176
180
const ev = DDUtils . initEvent < MouseEvent > ( event , { type : 'resize' , target : this . el } ) ;
@@ -194,6 +198,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
194
198
delete this . originalRect ;
195
199
delete this . temporalRect ;
196
200
delete this . scrollY ;
201
+ delete this . scrolled ;
197
202
return this ;
198
203
}
199
204
@@ -222,13 +227,11 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
222
227
/** @internal */
223
228
private _getChange ( event : MouseEvent , dir : string ) : Rect {
224
229
const oEvent = this . startEvent ;
225
- const scrollEl = Utils . getScrollParent ( this . el ) ;
226
- const scrolled = scrollEl === null ? 0 : ( scrollEl . scrollTop - this . scrollY ) ;
227
230
const newRect = { // Note: originalRect is a complex object, not a simple Rect, so copy out.
228
231
width : this . originalRect . width ,
229
- height : this . originalRect . height + scrolled ,
232
+ height : this . originalRect . height + this . scrolled ,
230
233
left : this . originalRect . left ,
231
- top : this . originalRect . top - scrolled
234
+ top : this . originalRect . top - this . scrolled
232
235
} ;
233
236
234
237
const offsetH = event . clientX - oEvent . clientX ;
@@ -300,14 +303,12 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
300
303
301
304
/** @internal */
302
305
private _ui = ( ) : DDUIData => {
303
- const scrollEl = Utils . getScrollParent ( this . el ) ;
304
- const scrolled = scrollEl === null ? 0 : ( scrollEl . scrollTop - this . scrollY ) ;
305
306
const containmentRect = this . el . parentElement . getBoundingClientRect ( ) ;
306
307
const newRect = { // Note: originalRect is a complex object, not a simple Rect, so copy out.
307
308
width : this . originalRect . width ,
308
- height : this . originalRect . height + scrolled ,
309
+ height : this . originalRect . height + this . scrolled ,
309
310
left : this . originalRect . left ,
310
- top : this . originalRect . top - scrolled
311
+ top : this . originalRect . top - this . scrolled
311
312
} ;
312
313
const rect = this . temporalRect || newRect ;
313
314
return {
0 commit comments