Skip to content

Commit

Permalink
Change temp views adding order
Browse files Browse the repository at this point in the history
  • Loading branch information
av0c0der committed Jul 8, 2017
1 parent 8953e6f commit de07c59
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions GlidingCollection/GlidingCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@ extension GlidingCollection {
let newCellSnapshotView = UIImageView()
let newRightSideSnapshotView = UIImageView()

containerView.addSubview(oldCellSnapshotView)
containerView.addSubview(oldRightSideSnapshotView)
containerView.addSubview(newCellShadowView)
containerView.addSubview(newCellWrapperView)
containerView.addSubview(newRightSideSnapshotView)

let unified = topViews + bottomViews
let movingItem = unified[safe: index]
topViews = Array(unified.prefix(through: index))
Expand Down Expand Up @@ -312,7 +318,7 @@ extension GlidingCollection {
cell.layer.render(in: context)
}
oldCellSnapshotView.image = UIGraphicsGetImageFromCurrentImageContext()
containerView.addSubview(oldCellSnapshotView)

oldCellSnapshotView.frame = oldCellFrame
UIGraphicsEndImageContext()
oldCellSnapshotView.tag = AnimationItem.oldCell.tag
Expand All @@ -327,7 +333,6 @@ extension GlidingCollection {
}
oldRightSideSnapshotView.image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
containerView.addSubview(oldRightSideSnapshotView)
oldRightSideSnapshotView.frame = CGRect(x: oldCellFrame.maxX + space, y: cellFrame.minY, width: cellFrame.width, height: cellFrame.height)
oldRightSideSnapshotView.tag = AnimationItem.oldRightSide.tag
setShadow(to: oldRightSideSnapshotView)
Expand Down Expand Up @@ -363,8 +368,6 @@ extension GlidingCollection {
newCellWrapperView.addSubview(newCellSnapshotView)
newCellWrapperView.clipsToBounds = true
newCellWrapperView.isUserInteractionEnabled = false
containerView.addSubview(newCellShadowView)
containerView.addSubview(newCellWrapperView)

let imageViewOriginY = up ? -cellFrame.height : 0
newCellSnapshotView.frame = CGRect(x: 0, y: imageViewOriginY, width: cellFrame.width, height: cellFrame.height)
Expand Down Expand Up @@ -393,7 +396,6 @@ extension GlidingCollection {
}
newRightSideSnapshotView.image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
containerView.addSubview(newRightSideSnapshotView)
newRightSideSnapshotView.frame = CGRect(x: bounds.maxX, y: cellFrame.minY, width: cell.bounds.width, height: cell.bounds.height)
newRightSideSnapshotView.tag = AnimationItem.newRightSide.tag
setShadow(to: newRightSideSnapshotView)
Expand Down

0 comments on commit de07c59

Please sign in to comment.