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

Fix UIStackView Layout issue during transition #22

Merged
merged 1 commit into from
Jan 7, 2017
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
8 changes: 4 additions & 4 deletions Hero/Hero.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ internal extension Hero {
for (currentFromViews, currentToViews) in self.animatorViews {
// auto hide all animated views
for v in currentFromViews{
v.isHidden = true
self.context.hide(view: v)
}
for v in currentToViews{
v.isHidden = true
self.context.hide(view: v)
}
}

Expand Down Expand Up @@ -210,10 +210,10 @@ internal extension Hero {
for (i, animator) in self.animators.enumerated(){
animator.clean()
for v in self.animatorViews[i].0{
v.isHidden = false
context.unhide(view:v)
}
for v in self.animatorViews[i].1{
v.isHidden = false
context.unhide(view:v)
}
}

Expand Down
18 changes: 16 additions & 2 deletions Hero/HeroContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class HeroContext {
fileprivate var heroIDToDestinationView = [String:UIView]()
fileprivate var snapshotViews = [UIView:UIView]()
fileprivate var modifiers = [UIView:HeroModifiers]()
fileprivate var viewAlphas = [UIView:CGFloat]()

internal init(container:UIView, fromView:UIView, toView:UIView){
fromViews = HeroContext.processViewTree(view: fromView, container: container, idMap: &heroIDToSourceView, modifierMap: &modifiers)
Expand Down Expand Up @@ -94,7 +95,7 @@ extension HeroContext{
return snapshot
}

view.isHidden = false
unhide(view: view)

// capture a snapshot without cornerRadius
let oldCornerRadius = view.layer.cornerRadius
Expand Down Expand Up @@ -142,7 +143,7 @@ extension HeroContext{
snapshot.frame = container.convert(view.bounds, from: view)
snapshot.heroID = view.heroID

view.isHidden = true
hide(view: view)

container.addSubview(snapshot)
snapshotViews[view] = snapshot
Expand Down Expand Up @@ -220,6 +221,19 @@ extension HeroContext{

// internal
extension HeroContext{
internal func hide(view:UIView) {
if viewAlphas[view] == nil{
viewAlphas[view] = view.alpha
view.alpha = 0
}
}
internal func unhide(view:UIView){
if let oldAlpha = viewAlphas[view]{
view.alpha = oldAlpha
viewAlphas[view] = nil
}
}

internal static func extractModifiers(modifierString:String) -> HeroModifiers {
func matches(for regex: String, text:NSString) -> [NSTextCheckingResult] {
do {
Expand Down