Skip to content

Commit

Permalink
0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
lkzhao committed Dec 31, 2016
1 parent 68a713b commit 03ed995
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 73 deletions.
4 changes: 0 additions & 4 deletions Examples/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Hero.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Hero"
s.version = "0.0.2"
s.version = "0.0.3"
s.summary = "Supercharged transition engine for iOS."

s.description = <<-DESC
Expand Down
5 changes: 2 additions & 3 deletions Hero/Hero.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import UIKit

internal class Hero:NSObject {
var toViewController:UIViewController?
var fromViewController:UIViewController?
weak var toViewController:UIViewController?
weak var fromViewController:UIViewController?

var interactive:Bool = false

Expand All @@ -51,7 +51,6 @@ internal class Hero:NSObject {
fileprivate var plugins:[HeroPlugin]!

fileprivate static let builtInProcessors:[HeroPreprocessor] = [
TrackSubviewPreprocessor(),
ClearModifierPreprocessor(),
ViewToViewPreprocessor(),
SourceIDPreprocessor(),
Expand Down
16 changes: 9 additions & 7 deletions Hero/HeroDefaultAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,18 @@
import UIKit

public class HeroDefaultAnimator:HeroAnimator{
var duration:TimeInterval = 0

var context:HeroContext!
let animatableOptions:Set<String> = ["fade", "opacity", "position", "size", "cornerRadius", "transform", "scale", "translate", "rotate"]
var viewContexts:[UIView: HeroDefaultAnimatorViewContext] = [:]

public func seekTo(timePassed:TimeInterval) {
for (_, viewContext) in viewContexts{
for viewContext in viewContexts.values{
viewContext.seek(timePassed: timePassed)
}
}

public func resume(timePassed:TimeInterval, reverse:Bool) -> TimeInterval{
duration = 0
var duration:TimeInterval = 0
for view in viewContexts.keys{
viewContexts[view]!.resume(timePassed: timePassed, reverse: reverse)
duration = max(duration, viewContexts[view]!.duration)
Expand Down Expand Up @@ -96,8 +94,7 @@ public class HeroDefaultAnimator:HeroAnimator{
snapshot.heroID = v.heroID

v.isHidden = true

// insert below views from other plugins

context.container.addSubview(snapshot)

return snapshot
Expand All @@ -106,13 +103,19 @@ public class HeroDefaultAnimator:HeroAnimator{
public func animate(context:HeroContext, fromViews:[UIView], toViews:[UIView]) -> TimeInterval{
self.context = context

var duration:TimeInterval = 0

// animate
for v in fromViews{
animate(view: v, appearing: false)
}
for v in toViews{
animate(view: v, appearing: true)
}

for viewContext in viewContexts.values{
duration = max(duration, viewContext.duration)
}

return duration
}
Expand All @@ -121,7 +124,6 @@ public class HeroDefaultAnimator:HeroAnimator{
let snapshot = takeSnapshot(for: view)
let viewContext = HeroDefaultAnimatorViewContext(animator:self, view: view, snapshot: snapshot, modifiers: context[view]!, appearing: appearing)
viewContexts[view] = viewContext
duration = max(duration, viewContext.duration)
}

public func clean(){
Expand Down
10 changes: 6 additions & 4 deletions Hero/HeroDefaultAnimatorViewContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ internal class HeroDefaultAnimatorViewContext {
return animator!.context.container
}

/*
// return (delay, duration, easing)
func getTiming(key:String, fromValue:Any?, toValue:Any?) -> (TimeInterval, TimeInterval, CAMediaTimingFunction){
// delay should be for a specific animation. this shouldn't include the baseDelay

// TODO: dynamic delay and duration for different key
// https://material.io/guidelines/motion/choreography.html#choreography-continuity
/*

switch key {
case "opacity":
if let value = (toValue as? NSNumber)?.floatValue{
Expand All @@ -70,14 +71,15 @@ internal class HeroDefaultAnimatorViewContext {
default:
break
}
*/
return (0, defaultTiming.0, defaultTiming.1)
return (0.0, defaultTiming.0, defaultTiming.1)
}
*/

func getAnimation(key:String, beginTime:TimeInterval, fromValue:Any?, toValue:Any?, ignoreArc:Bool = false) -> CAPropertyAnimation {
let anim:CAPropertyAnimation

let (delay, duration, timingFunction) = getTiming(key: key, fromValue: fromValue, toValue: toValue)
let (delay, duration, timingFunction) = (0.0, defaultTiming.0, defaultTiming.1)
// getTiming(key: key, fromValue: fromValue, toValue: toValue)

if !ignoreArc, key == "position", let arcOptions = parameters["arc"],
let fromPos = (fromValue as? NSValue)?.cgPointValue,
Expand Down
54 changes: 0 additions & 54 deletions Hero/TrackSubviewPreprocessor.swift

This file was deleted.

0 comments on commit 03ed995

Please sign in to comment.