@@ -40,3 +40,49 @@ extension AtomicTransition {
4040 }
4141 }
4242}
43+
44+ public struct Move : AtomicTransitionProtocol {
45+ private let edge : Edge
46+
47+ public init ( edge: Edge ) {
48+ self . edge = edge
49+ }
50+
51+ public func transition( _ view: TransientView , for operation: TransitionOperation , in container: Container ) {
52+ switch ( edge, operation) {
53+ case ( . top, . insertion) :
54+ view. initial. translation. dy = - container. frame. height
55+ view. animation. translation. dy = 0
56+
57+ case ( . leading, . insertion) :
58+ view. initial. translation. dx = - container. frame. width
59+ view. animation. translation. dx = 0
60+
61+ case ( . trailing, . insertion) :
62+ view. initial. translation. dx = container. frame. width
63+ view. animation. translation. dx = 0
64+
65+ case ( . bottom, . insertion) :
66+ view. initial. translation. dy = container. frame. height
67+ view. animation. translation. dy = 0
68+
69+ case ( . top, . removal) :
70+ view. animation. translation. dy = - container. frame. height
71+ view. completion. translation. dy = 0
72+
73+ case ( . leading, . removal) :
74+ view. animation. translation. dx = - container. frame. width
75+ view. completion. translation. dx = 0
76+
77+ case ( . trailing, . removal) :
78+ view. animation. translation. dx = container. frame. width
79+ view. completion. translation. dx = 0
80+
81+ case ( . bottom, . removal) :
82+ view. animation. translation. dy = container. frame. height
83+ view. completion. translation. dy = 0
84+ }
85+ }
86+ }
87+
88+ extension Move : Hashable { }
0 commit comments