Skip to content

Commit

Permalink
Take care of the frame right before the animation
Browse files Browse the repository at this point in the history
In case a rendering is scheduled already...
  • Loading branch information
danielgindi committed Jul 14, 2015
1 parent 0f4962d commit 15b3f43
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Charts/Classes/Animation/ChartAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@ public class ChartAnimator: NSObject
}
}

@objc private func animationLoop()
private func updateAnimationPhases(currentTime: NSTimeInterval)
{
var currentTime: NSTimeInterval = CACurrentMediaTime()
var elapsedTime: NSTimeInterval = currentTime - _startTime
if (_enabledX)
{
Expand Down Expand Up @@ -123,6 +122,13 @@ public class ChartAnimator: NSObject
phaseY = CGFloat(elapsed / duration)
}
}
}

@objc private func animationLoop()
{
var currentTime: NSTimeInterval = CACurrentMediaTime()

updateAnimationPhases(currentTime)

if (delegate != nil)
{
Expand Down Expand Up @@ -163,6 +169,9 @@ public class ChartAnimator: NSObject
_easingX = easingX
_easingY = easingY

// Take care of the first frame if rendering is already scheduled...
updateAnimationPhases(_startTime)

if (_enabledX || _enabledY)
{
_displayLink.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
Expand Down Expand Up @@ -260,4 +269,4 @@ public class ChartAnimator: NSObject
{
animate(xAxisDuration: 0.0, yAxisDuration: yAxisDuration, easingOption: .EaseInOutSine)
}
}
}

0 comments on commit 15b3f43

Please sign in to comment.