From d38a8089b93a624928f5c568160ebd3a0c2cdb4f Mon Sep 17 00:00:00 2001 From: jljsj Date: Tue, 8 Dec 2020 22:20:43 +0800 Subject: [PATCH] fix cr --- src/Slider.tsx | 6 +++++- src/common/createSlider.tsx | 5 ++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Slider.tsx b/src/Slider.tsx index 5adc56f02..2a5e86767 100644 --- a/src/Slider.tsx +++ b/src/Slider.tsx @@ -62,6 +62,10 @@ class Slider extends React.Component { return 0; } + positionGetValue = (position): number[] => { + return []; + }; + calcOffset(value: number) { return 0; } @@ -246,7 +250,7 @@ class Slider extends React.Component { ariaLabelledBy: ariaLabelledByForHandle, ariaValueTextFormatter: ariaValueTextFormatterForHandle, style: handleStyle[0] || handleStyle, - ref: h => this.saveHandle(0, h), + ref: (h) => this.saveHandle(0, h), }); const trackOffset = startPoint !== undefined ? this.calcOffset(startPoint) : 0; diff --git a/src/common/createSlider.tsx b/src/common/createSlider.tsx index bde5fc80b..45da8d082 100644 --- a/src/common/createSlider.tsx +++ b/src/common/createSlider.tsx @@ -106,7 +106,7 @@ export default function createSlider< const { draggableTrack, vertical: isVertical } = this.props; const { bounds } = this.state; - const value = this.positionGetValue(p) || []; + const value = draggableTrack && this.positionGetValue ? this.positionGetValue(p) || [] : []; const inPoint = utils.isEventFromHandle(e, this.handlesRefs); this.inTrack = @@ -119,8 +119,6 @@ export default function createSlider< }) .some((c) => !c); - const handlePosition = utils.getHandleCenterPosition(isVertical, e.target); - if (this.inTrack) { this.dragOffset = p; this.startBounds = [...bounds]; @@ -128,6 +126,7 @@ export default function createSlider< if (!inPoint) { this.dragOffset = 0; } else { + const handlePosition = utils.getHandleCenterPosition(isVertical, e.target); this.dragOffset = p - handlePosition; p = handlePosition; }