Skip to content

Commit

Permalink
Fixed (again...) the highlight vs. drag issue (Closes #520, closes #521)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Oct 30, 2015
1 parent a9ca92a commit d389c4f
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions Charts/Classes/Charts/BarLineChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -763,15 +763,23 @@ public class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChar
{
stopDeceleration()

if !_dataNotSet && _dragEnabled &&
(!self.hasNoDragOffset || !self.isFullyZoomedOut || self.isHighlightPerDragEnabled)
if _dataNotSet
{ // If we have no data, we have nothing to pan and no data to highlight
return;
}

// If drag is enabled and we are in a position where there's something to drag:
// * If we're zoomed in, then obviously we have something to drag.
// * If we have a drag offset - we always have something to drag
if self.isDragEnabled &&
(!self.hasNoDragOffset || !self.isFullyZoomedOut)
{
_isDragging = true

_closestDataSetToTouch = getDataSetByTouchPoint(recognizer.locationOfTouch(0, inView: self))

let translation = recognizer.translationInView(self)
let didUserDrag = (self is HorizontalBarChartView) ? translation.y != 0.0 : translation.x != 0.0
let didUserDrag = (self is HorizontalBarChartView) ? translation.y != 0.0 : translation.x != 0.0

// Check to see if user dragged at all and if so, can the chart be dragged by the given amount
if (didUserDrag && !performPanChange(translation: translation))
Expand All @@ -794,6 +802,12 @@ public class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChar

_lastPanPoint = recognizer.translationInView(self)
}
else if self.isHighlightPerDragEnabled
{
// We will only handle highlights on UIGestureRecognizerState.Changed

_isDragging = false
}
}
else if (recognizer.state == UIGestureRecognizerState.Changed)
{
Expand Down

0 comments on commit d389c4f

Please sign in to comment.