From df70f8d7180418f0a09ab48443fd01618cadb153 Mon Sep 17 00:00:00 2001 From: Nagendra Muralidhar Pulla Date: Tue, 23 May 2023 09:57:36 +0530 Subject: [PATCH] fix(allowCross): When two handles coincide (i.e pushNum = 0 || pushable = false, allowCross === false ) and you can move the handle across the other handle which should not be the case --- src/hooks/useOffset.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/hooks/useOffset.ts b/src/hooks/useOffset.ts index c80d0122a..f46dd8fbe 100644 --- a/src/hooks/useOffset.ts +++ b/src/hooks/useOffset.ts @@ -220,6 +220,24 @@ export default function useOffset( nextValues[valueIndex + 1] - pushNum, ); } + + if (valueIndex > 0 && nextValues[valueIndex - 1] === originValue && pushNum === 0) { + nextValues[valueIndex] = Math.max( + nextValues[valueIndex], + nextValues[valueIndex - 1] + pushNum, + ); + } + + if ( + valueIndex < nextValues.length - 1 && + nextValues[valueIndex + 1] === originValue && + pushNum === 0 + ) { + nextValues[valueIndex] = Math.min( + nextValues[valueIndex], + nextValues[valueIndex + 1] + pushNum, + ); + } } else if (typeof pushable === 'number' || pushable === null) { // >>>>> Pushable // =============== Push ==================