Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue when you can't drag and drop upper thumb back after moving it to the left side because lower thumb always active thumb in tis case, but it stay on 0 position and can't be moved. #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions lib/src/flutter_range_slider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,20 @@ class _RenderRangeSlider extends RenderBox {
_ActiveThumb _previousActiveThumb = _ActiveThumb.none;

_validateActiveThumb(Offset position) {

void setUpperThumbAsActive(double divisionOffset) {
_activeThumb = _ActiveThumb.upperThumb;
_minDragValue = _discretize(_lowerValue + divisionOffset);
_maxDragValue = 1.0;
}

void setLowerThumbAsActive(double divisionOffset) {
_activeThumb = _ActiveThumb.lowerThumb;
_minDragValue = 0.0;
_maxDragValue = _discretize(_upperValue - divisionOffset);
}


var _thumbLowerExpandedRect = Rect.fromCircle(
center: _thumbLowerRect.centerLeft,
radius: _thumbRadius * _touchRadiusExpansionRatio);
Expand All @@ -1288,14 +1302,16 @@ class _RenderRangeSlider extends RenderBox {
: (_thumbRadius * 2.0) / _trackLength;
double divisionOffset = _allowThumbOverlap ? 0.0 : calculatedDivisionOffset;

if (_thumbLowerExpandedRect.contains(position)) {
_activeThumb = _ActiveThumb.lowerThumb;
_minDragValue = 0.0;
_maxDragValue = _discretize(_upperValue - divisionOffset);
if (_thumbLowerExpandedRect.contains(position) && _thumbUpperExpandedRect.contains(position)) {
if (_upperValue < 0.5) {
setUpperThumbAsActive(divisionOffset);
} else {
setLowerThumbAsActive(divisionOffset);
}
} else if (_thumbLowerExpandedRect.contains(position)) {
setLowerThumbAsActive(divisionOffset);
} else if (_thumbUpperExpandedRect.contains(position)) {
_activeThumb = _ActiveThumb.upperThumb;
_minDragValue = _discretize(_lowerValue + divisionOffset);
_maxDragValue = 1.0;
setUpperThumbAsActive(divisionOffset);
} else {
_activeThumb = _ActiveThumb.none;
}
Expand Down