Skip to content

Commit

Permalink
fixes the following issue:
Browse files Browse the repository at this point in the history
When trying to zoom in/out using the pinch gesture when the zoom in/out limit is reached the chart starts to pan.

I'm not sure this is the best way to solve this issue
  • Loading branch information
Dor Alon committed May 31, 2015
1 parent 7938ae1 commit bd1549c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Charts/Classes/Charts/BarLineChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,9 @@ public class BarLineChartViewBase: ChartViewBase, UIGestureRecognizerDelegate
}
else if (recognizer.state == UIGestureRecognizerState.Changed)
{
if (_isScaling)
var isZoomingOut = (recognizer.scale < 1);
var canZoomMore = isZoomingOut ? _viewPortHandler.canZoomOutMore() : _viewPortHandler.canZoomInMore();
if (_isScaling && canZoomMore)
{
var location = recognizer.locationInView(self);
location.x = location.x - _viewPortHandler.offsetLeft;
Expand Down
10 changes: 10 additions & 0 deletions Charts/Classes/Utils/ChartViewPortHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -407,4 +407,14 @@ public class ChartViewPortHandler: NSObject
_maxScaleX = maxScaleX;
setMinimumScaleX(minScaleX);
}

public func canZoomOutMore() -> Bool
{
return (_scaleX > _minScaleX);
}

public func canZoomInMore() -> Bool
{
return (_scaleX < _maxScaleX);
}
}

0 comments on commit bd1549c

Please sign in to comment.