@@ -5,20 +5,14 @@ import { EventBuilder } from '../event-builder';
5
5
import { ErrorWithStack } from '../../helpers/errors' ;
6
6
import { isHostScrollView } from '../../helpers/host-component-names' ;
7
7
import { pick } from '../../helpers/object' ;
8
- import { ContentOffset } from '../event-builder/scroll-view' ;
8
+ import { nativeState } from '../../native-state' ;
9
+ import { Point , Size } from '../../types' ;
9
10
import { dispatchEvent , wait } from '../utils' ;
10
11
import { createScrollSteps , inertialInterpolator , linearInterpolator } from './utils' ;
11
- import { getElementScrollOffset , setElementScrollOffset } from './state' ;
12
12
13
13
interface CommonScrollToOptions {
14
- contentSize ?: {
15
- height : number ;
16
- width : number ;
17
- } ;
18
- layoutMeasurement ?: {
19
- height : number ;
20
- width : number ;
21
- } ;
14
+ contentSize ?: Size ;
15
+ layoutMeasurement ?: Size ;
22
16
}
23
17
24
18
export interface VerticalScrollToOptions extends CommonScrollToOptions {
@@ -62,7 +56,7 @@ export async function scrollTo(
62
56
options . contentSize ?. height ?? 0 ,
63
57
) ;
64
58
65
- const initialPosition = getElementScrollOffset ( element ) ;
59
+ const initialPosition = nativeState ?. contentOffsetForElement . get ( element ) ?? { x : 0 , y : 0 } ;
66
60
const dragSteps = createScrollSteps (
67
61
{ y : options . y , x : options . x } ,
68
62
initialPosition ,
@@ -79,13 +73,13 @@ export async function scrollTo(
79
73
await emitMomentumScrollEvents ( this . config , element , momentumSteps , options ) ;
80
74
81
75
const finalPosition = momentumSteps . at ( - 1 ) ?? dragSteps . at ( - 1 ) ?? initialPosition ;
82
- setElementScrollOffset ( element , finalPosition ) ;
76
+ nativeState ?. contentOffsetForElement . set ( element , finalPosition ) ;
83
77
}
84
78
85
79
async function emitDragScrollEvents (
86
80
config : UserEventConfig ,
87
81
element : ReactTestInstance ,
88
- scrollSteps : ContentOffset [ ] ,
82
+ scrollSteps : Point [ ] ,
89
83
scrollOptions : ScrollToOptions ,
90
84
) {
91
85
if ( scrollSteps . length === 0 ) {
@@ -115,7 +109,7 @@ async function emitDragScrollEvents(
115
109
async function emitMomentumScrollEvents (
116
110
config : UserEventConfig ,
117
111
element : ReactTestInstance ,
118
- scrollSteps : ContentOffset [ ] ,
112
+ scrollSteps : Point [ ] ,
119
113
scrollOptions : ScrollToOptions ,
120
114
) {
121
115
if ( scrollSteps . length === 0 ) {
0 commit comments