File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -322,6 +322,19 @@ const dragThreshold = computed(() => {
322322 return w / (props .max - props .min );
323323});
324324
325+ const selectionWidth = computed (() => {
326+ const w = zoomWrapper .value .getBoundingClientRect ().width - 48 ;
327+ return w / (props .max - props .min ) * currentRange .value ;
328+ })
329+
330+ const RA_SPECIAL_MAGIC_NUMBER = ref (2.5 );
331+
332+ const flooredDatapointsToWidth = computed (() => {
333+ const w = zoomWrapper .value .getBoundingClientRect ().width - 48 ;
334+
335+ return Math .ceil ((props .max - props .min ) / ((w - selectionWidth .value ) / RA_SPECIAL_MAGIC_NUMBER .value ));
336+ })
337+
325338const startDragging = (event ) => {
326339 if (! props .enableSelectionDrag ) {
327340 return ;
@@ -361,13 +374,13 @@ function updateDragging(currentX) {
361374 if (Math .abs (deltaX) > dragThreshold .value ) {
362375 if (deltaX > 0 ) {
363376 if (Number (endValue .value ) + 1 <= props .max ) {
364- const v = Number (endValue .value ) + 1 ;
377+ const v = Math . min ( props . max , Number (endValue .value ) + flooredDatapointsToWidth . value )
365378 setEndValue (v);
366379 setStartValue (v - currentRange .value );
367380 }
368381 } else {
369382 if (Number (startValue .value ) - 1 >= props .min ) {
370- const v = Number (startValue .value ) - 1 ;
383+ const v = Math . max ( 0 , Number (startValue .value ) - flooredDatapointsToWidth . value ) ;
371384 setStartValue (v);
372385 setEndValue (v + currentRange .value );
373386 }
You can’t perform that action at this time.
0 commit comments