File tree 2 files changed +8
-1
lines changed
2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -437,6 +437,8 @@ type ScrollControlsProps = {
437
437
* then a maxSpeed of e.g. 0.1 which will clamp the speed to 0.1 units per second, it may now
438
438
* take much longer than damping to reach the target if it is far away. Default: Infinity */
439
439
maxSpeed? : number
440
+ /** If true attaches the scroll container before the canvas */
441
+ prepend? : boolean
440
442
enabled? : boolean
441
443
style? : React .CSSProperties
442
444
children: React .ReactNode
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ export type ScrollControlsProps = {
24
24
* then a maxSpeed of e.g. 3 which will clamp the speed to 3 units per second, it may now
25
25
* take much longer than damping to reach the target if it is far away. Default: Infinity */
26
26
maxSpeed ?: number
27
+ /** If true attaches the scroll container before the canvas */
28
+ prepend ?: boolean
27
29
enabled ?: boolean
28
30
style ?: React . CSSProperties
29
31
children : React . ReactNode
@@ -59,6 +61,7 @@ export function ScrollControls({
59
61
distance = 1 ,
60
62
damping = 0.25 ,
61
63
maxSpeed = Infinity ,
64
+ prepend = false ,
62
65
style = { } ,
63
66
children,
64
67
} : ScrollControlsProps ) {
@@ -126,7 +129,9 @@ export function ScrollControls({
126
129
fill . style . width = horizontal ? `${ pages * distance * 100 } %` : '100%'
127
130
fill . style . pointerEvents = 'none'
128
131
el . appendChild ( fill )
129
- target . appendChild ( el )
132
+
133
+ if ( prepend ) target . prepend ( el )
134
+ else target . appendChild ( el )
130
135
131
136
// Init scroll one pixel in to allow upward/leftward scroll
132
137
el [ horizontal ? 'scrollLeft' : 'scrollTop' ] = 1
You can’t perform that action at this time.
0 commit comments