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

Only alow scaling further if the user can still zoom (Fixes #437) #438

Merged
merged 2 commits into from
Oct 15, 2015
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions Charts/Classes/Charts/BarLineChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -725,10 +725,11 @@ public class BarLineChartViewBase: ChartViewBase, UIGestureRecognizerDelegate
{
let isZoomingOut = (recognizer.scale < 1)
let canZoomMoreX = isZoomingOut ? _viewPortHandler.canZoomOutMoreX : _viewPortHandler.canZoomInMoreX
let canZoomMoreY = isZoomingOut ? _viewPortHandler.canZoomOutMoreY : _viewPortHandler.canZoomInMoreY

if (_isScaling)
if (_isScaling && canZoomMoreX && canZoomMoreY)
{
if (canZoomMoreX || (_gestureScaleAxis == .Both || _gestureScaleAxis == .Y && _scaleYEnabled))
if (_gestureScaleAxis == .Both || _gestureScaleAxis == .Y && _scaleYEnabled)
{
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 @@ -457,4 +457,14 @@ public class ChartViewPortHandler: NSObject
{
return (_scaleX < _maxScaleX)
}

public var canZoomOutMoreY: Bool
{
return (_scaleY > _minScaleY)
}

public var canZoomInMoreY: Bool
{
return (_scaleY < _maxScaleY)
}
}