-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPaperPlaneView.swift
More file actions
44 lines (38 loc) · 1.31 KB
/
Copy pathPaperPlaneView.swift
File metadata and controls
44 lines (38 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
// PaperPlaneView.swift
// AnimationExamples
//
// Created by Esat Gözcü on 2023/03/13.
//
import SwiftUI
struct PaperPlaneView: View {
@StateObject var viewModel = PaperPlaneVM()
@State var action = false
var body: some View {
GeometryReader { geo in
ForEach(0..<viewModel.itemSize, id: \.self) { id in
Image("paper_plane")
.resizable()
.frame(width: viewModel.randomSize[id],
height: viewModel.randomSize[id]
)
.offset(x: action ? (geo.size.width + viewModel.randomSize[id]) : -viewModel.randomSize[id],
y: action ? (viewModel.randomYList[id] - geo.size.width) : viewModel.randomYList[id]
)
.animation(
.linear(duration: Double(viewModel.randomDurationMillis[id])/1000)
.delay(Double(viewModel.randomDelayMillis[id])/1000)
.repeatCount(10, autoreverses: false)
)
}
}.ignoresSafeArea()
.onAppear{
action = true
}
}
}
struct PaperPlaneView_Preview: PreviewProvider {
static var previews: some View {
PaperPlaneView()
}
}