Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. static final RangeThumbSelector _defaultRangeThumbSelector = (
  2. TextDirection textDirection,
  3. RangeValues values,
  4. double tapValue,
  5. Size thumbSize,
  6. Size trackSize,
  7. double dx, // drag displacement
  8. ) {
  9. final double touchRadius = math.max(thumbSize.width, RangeSlider._minTouchTargetWidth) / 2;
  10.  
  11. final bool inStartTouchTarget = (tapValue - values.start).abs() * trackSize.width < touchRadius;
  12.  
  13. final bool inEndTouchTarget = (tapValue - values.end).abs() * trackSize.width < touchRadius;
  14.  
  15.  
  16. if (inStartTouchTarget && inEndTouchTarget) {
  17. bool towardsStart;
  18. bool towardsEnd;
  19. switch (textDirection) {
  20. case TextDirection.ltr:
  21. towardsStart = dx < 0;
  22. towardsEnd = dx > 0;
  23. break;
  24. case TextDirection.rtl:
  25. towardsStart = dx > 0;
  26. towardsEnd = dx < 0;
  27. break;
  28. }
  29. if (towardsStart)
  30. return Thumb.start;
  31. if (towardsEnd)
  32. return Thumb.end;
  33. } else {
  34. if (tapValue < values.start || inStartTouchTarget)
  35. return Thumb.start;
  36. if (tapValue > values.end || inEndTouchTarget)
  37. return Thumb.end;
  38. }
  39. return null;
  40. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement