@@ -50,6 +50,7 @@ interface HarnessOptions {
5050 valueMax ?: number
5151 showMidpoint ?: boolean
5252 track ?: HTMLElement | null
53+ contentInsetX ?: number
5354}
5455
5556interface Harness {
@@ -72,6 +73,7 @@ const mountRangeEditor = (opts: HarnessOptions = {}): Harness => {
7273 const valueMin = ref ( opts . valueMin ?? 0 )
7374 const valueMax = ref ( opts . valueMax ?? 100 )
7475 const showMidpoint = ref ( opts . showMidpoint ?? true )
76+ const contentInsetX = ref ( opts . contentInsetX ?? 0 )
7577
7678 let api : ReturnType < typeof useRangeEditor > | undefined
7779 const TestComponent = defineComponent ( {
@@ -81,7 +83,8 @@ const mountRangeEditor = (opts: HarnessOptions = {}): Harness => {
8183 modelValue,
8284 valueMin,
8385 valueMax,
84- showMidpoint
86+ showMidpoint,
87+ contentInsetX
8588 } )
8689 return ( ) => null
8790 }
@@ -323,4 +326,44 @@ describe('useRangeEditor', () => {
323326 expect . arrayContaining ( [ 'pointermove' , 'pointerup' , 'lostpointercapture' ] )
324327 )
325328 } )
329+
330+ it ( 'maps pointer at content inset to valueMin when contentInsetX is set' , ( ) => {
331+ harness = mountRangeEditor ( {
332+ initial : { min : 20 , max : 80 , midpoint : 0.5 } ,
333+ valueMin : 0 ,
334+ valueMax : 100 ,
335+ showMidpoint : false ,
336+ contentInsetX : 16
337+ } )
338+
339+ harness . api . startDrag (
340+ 'min' ,
341+ createPointerEvent ( 'pointerdown' , { clientX : 16 } )
342+ )
343+ harness . trackRef . value ! . dispatchEvent (
344+ createPointerEvent ( 'pointermove' , { clientX : 16 } )
345+ )
346+
347+ expect ( harness . modelValue . value . min ) . toBe ( 0 )
348+ } )
349+
350+ it ( 'maps pointer at right content inset to valueMax when contentInsetX is set' , ( ) => {
351+ harness = mountRangeEditor ( {
352+ initial : { min : 0 , max : 80 , midpoint : 0.5 } ,
353+ valueMin : 0 ,
354+ valueMax : 100 ,
355+ showMidpoint : false ,
356+ contentInsetX : 16
357+ } )
358+
359+ harness . api . startDrag (
360+ 'max' ,
361+ createPointerEvent ( 'pointerdown' , { clientX : 184 } )
362+ )
363+ harness . trackRef . value ! . dispatchEvent (
364+ createPointerEvent ( 'pointermove' , { clientX : 184 } )
365+ )
366+
367+ expect ( harness . modelValue . value . max ) . toBe ( 100 )
368+ } )
326369} )
0 commit comments