Skip to content

Commit

Permalink
More accessors on viewporthandler
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Mar 9, 2016
1 parent c6bfb03 commit c7e5ade
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions Charts/Classes/Utils/ChartViewPortHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public class ChartViewPortHandler: NSObject
/// limits the maximum scale and X translation of the given matrix
private func limitTransAndScale(inout matrix matrix: CGAffineTransform, content: CGRect?)
{
// min scale-x is 1, max is the max CGFloat
// min scale-x is 1
_scaleX = min(max(_minScaleX, matrix.a), _maxScaleX)

// min scale-y is 1
Expand All @@ -287,12 +287,10 @@ public class ChartViewPortHandler: NSObject
}

let maxTransX = -width * (_scaleX - 1.0)
let newTransX = min(max(matrix.tx, maxTransX - _transOffsetX), _transOffsetX)
_transX = newTransX
_transX = min(max(matrix.tx, maxTransX - _transOffsetX), _transOffsetX)

let maxTransY = height * (_scaleY - 1.0)
let newTransY = max(min(matrix.ty, maxTransY + _transOffsetY), -_transOffsetY)
_transY = newTransY
_transY = max(min(matrix.ty, maxTransY + _transOffsetY), -_transOffsetY)

matrix.tx = _transX
matrix.a = _scaleX
Expand Down Expand Up @@ -439,6 +437,30 @@ public class ChartViewPortHandler: NSObject
return _scaleY
}

/// - returns: the minimum x-scale factor
public var minScaleX: CGFloat
{
return _minScaleX
}

/// - returns: the minimum y-scale factor
public var minScaleY: CGFloat
{
return _minScaleY
}

/// - returns: the minimum x-scale factor
public var maxScaleX: CGFloat
{
return _maxScaleX
}

/// - returns: the minimum y-scale factor
public var maxScaleY: CGFloat
{
return _maxScaleY
}

/// - returns: the translation (drag / pan) distance on the x-axis
public var transX: CGFloat
{
Expand Down

0 comments on commit c7e5ade

Please sign in to comment.