Skip to content

Commit e66e1da

Browse files
committed
Revert "Contents animation to test"
This reverts commit 49162f7.
1 parent 7d5f8d2 commit e66e1da

File tree

7 files changed

+6
-127
lines changed

7 files changed

+6
-127
lines changed

Example/Example/Examples/Path/PathExampleView.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,4 @@ class PathExampleView: MacawView {
156156
shape.clip = RoundRect(rect: Rect(x: 0.0, y: 0.0, w: 10, h: 10))
157157
return [shape].group(place:.move(dx: 200, dy: 200))
158158
}
159-
160-
// fileprivate static func contentsScene() -> Node {
161-
// let shape = Shape(form: Arc( )
162-
// }
163-
//}
159+
}

Source/animation/AnimationImpl.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import RxSwift
1111

1212
enum AnimationType {
1313
case unknown
14-
case contents
1514
case affineTransformation
1615
case opacity
1716
case sequence

Source/animation/AnimationProducer.swift

Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,7 @@ let animationProducer = AnimationProducer()
44

55
class AnimationProducer {
66

7-
87
var storedAnimations = [Node: BasicAnimation]()
9-
var displayLink: CADisplayLink?
10-
11-
struct ContentAnimationDesc {
12-
let animation: ContentsAnimation
13-
let layer: CALayer
14-
let cache: AnimationCache
15-
let startDate: Date
16-
let finishDate: Date
17-
}
18-
19-
var contentsAnimations = [ContentAnimationDesc]()
208

219
func addAnimation(_ animation: BasicAnimation, withoutDelay: Bool = false) {
2210

@@ -67,14 +55,10 @@ class AnimationProducer {
6755
addAnimationSequence(animation)
6856
case .combine:
6957
addCombineAnimation(animation)
70-
case .contents:
71-
addContentsAnimation(animation, cache: cache)
7258
case .empty:
7359
executeCompletion(animation)
7460
}
7561
}
76-
77-
// MARK: - Sequence animation
7862
fileprivate func addAnimationSequence(_ animationSequnce: Animation) {
7963
guard let sequence = animationSequnce as? AnimationSequence else {
8064
return
@@ -127,7 +111,6 @@ class AnimationProducer {
127111
}
128112
}
129113

130-
// MARK: - Combine animation
131114
fileprivate func addCombineAnimation(_ combineAnimation: Animation) {
132115
guard let combine = combineAnimation as? CombineAnimation else {
133116
return
@@ -194,12 +177,10 @@ class AnimationProducer {
194177
}
195178
}
196179

197-
// MARK: - Empty Animation
198180
fileprivate func executeCompletion(_ emptyAnimation: BasicAnimation) {
199181
emptyAnimation.completion?()
200182
}
201-
202-
// MARK: - Stored animation
183+
203184
func addStoredAnimations(_ node: Node) {
204185
if let animation = storedAnimations[node] {
205186
addAnimation(animation)
@@ -214,63 +195,4 @@ class AnimationProducer {
214195
addStoredAnimations(child)
215196
}
216197
}
217-
218-
// MARK: - Contents animation
219-
220-
func addContentsAnimation(_ animation: BasicAnimation, cache: AnimationCache) {
221-
guard let contentsAnimation = animation as? ContentsAnimation else {
222-
return
223-
}
224-
225-
guard let node = contentsAnimation.node else {
226-
return
227-
}
228-
229-
let startDate = Date(timeInterval: contentsAnimation.delay, since: Date())
230-
231-
let animationDesc = ContentAnimationDesc(
232-
animation: contentsAnimation,
233-
layer: cache.layerForNode(node, animation: contentsAnimation),
234-
cache: cache,
235-
startDate: Date(),
236-
finishDate: Date(timeInterval: contentsAnimation.duration, since: startDate))
237-
238-
contentsAnimations.append(animationDesc)
239-
240-
if displayLink == .none {
241-
displayLink = CADisplayLink(target: self, selector: #selector(updateContentAnimations))
242-
displayLink?.frameInterval = 1
243-
displayLink?.add(to: RunLoop.current, forMode: RunLoopMode.defaultRunLoopMode)
244-
}
245-
246-
247-
}
248-
249-
@objc func updateContentAnimations() {
250-
if contentsAnimations.count == 0 {
251-
displayLink?.invalidate()
252-
displayLink = .none
253-
}
254-
255-
let currentDate = Date()
256-
for (index, animationDesc) in contentsAnimations.enumerated() {
257-
258-
let animation = animationDesc.animation
259-
guard let node = animation.node else {
260-
continue
261-
}
262-
263-
let progress = currentDate.timeIntervalSince(animationDesc.startDate) / animation.duration
264-
if progress >= 1.0 {
265-
animation.completion?()
266-
contentsAnimations.remove(at: index)
267-
animationDesc.cache.freeLayer(node)
268-
continue
269-
}
270-
271-
animation.getVFunc()(progress)
272-
animationDesc.layer.setNeedsDisplay()
273-
animation.onProgressUpdate?(progress)
274-
}
275-
}
276198
}

Source/animation/layer_animation/Extensions/GroupInterpolation.swift

Lines changed: 0 additions & 11 deletions
This file was deleted.

Source/animation/types/ContentsAnimation.swift

Lines changed: 0 additions & 20 deletions
This file was deleted.

Source/model/scene/Group.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@ import RxSwift
33

44
open class Group: Node {
55

6-
open var contentsVar: AnimatableVariable<[Node]>
7-
open var contents: [Node] {
8-
get { return contentsVar.value }
9-
set(val) { contentsVar.value = val }
10-
}
11-
6+
open var contents: ObservableArray<Node>
127

138
public init(contents: [Node] = [], place: Transform = Transform.identity, opaque: Bool = true, opacity: Double = 1, clip: Locus? = nil, effect: Effect? = nil, visible: Bool = true, tag: [String] = []) {
14-
self.contentsVar = AnimatableVariable<[Node]>(contents)
9+
self.contents = ObservableArray<Node>(contents)
1510
super.init(
1611
place: place,
1712
opaque: opaque,
@@ -21,8 +16,6 @@ open class Group: Node {
2116
visible: visible,
2217
tag: tag
2318
)
24-
25-
2619
}
2720

2821
// GENERATED NOT

Source/render/GroupRenderer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class GroupRenderer: NodeRenderer {
1616

1717
override func doAddObservers() {
1818
super.doAddObservers()
19-
observe(group.contentsVar.asObservable())
20-
addDisposable(group.contentsVar.asObservable().subscribeNext { event in self.updateRenderers() })
19+
observe(group.contents.rx_elements())
20+
addDisposable(group.contents.rx_elements().subscribeNext { event in self.updateRenderers() })
2121
}
2222

2323
override func node() -> Node {

0 commit comments

Comments
 (0)