Created
March 17, 2022 23:01
-
-
Save christianselig/e2424687091e26d32ec26a282c4e4dc5 to your computer and use it in GitHub Desktop.
slidey thingy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct ContentView: View { | |
| static let maskWidth = 136.0 | |
| static let duration = 5.0 | |
| @State var offset1 = -Self.maskWidth | |
| @State var offset2 = -Self.maskWidth | |
| @State var offset3 = -Self.maskWidth | |
| @State var offset4 = -Self.maskWidth | |
| @State var offset5 = -Self.maskWidth | |
| let rotationActive = true | |
| var body: some View { | |
| ZStack { | |
| wall1 | |
| .mask(alignment: .topLeading) { | |
| GeometryReader { geometry in | |
| Image("maskie2") | |
| .offset(x: offset1) | |
| .onAppear { | |
| let animation = Animation | |
| .linear(duration: Self.duration) | |
| .repeatForever(autoreverses: false) | |
| withAnimation(animation) { | |
| offset1 = geometry.size.width | |
| } | |
| } | |
| } | |
| } | |
| wall2 | |
| .mask(alignment: .topLeading) { | |
| GeometryReader { geometry in | |
| Image("maskie2") | |
| .offset(x: offset2) | |
| .onAppear { | |
| let animation = Animation | |
| .linear(duration: Self.duration) | |
| .repeatForever(autoreverses: false) | |
| .delay(100.0/87.0) | |
| withAnimation(animation) { | |
| offset2 = geometry.size.width | |
| } | |
| } | |
| } | |
| } | |
| wall3 | |
| .mask(alignment: .topLeading) { | |
| GeometryReader { geometry in | |
| Image("maskie2") | |
| .offset(x: offset3) | |
| .onAppear { | |
| let animation = Animation | |
| .linear(duration: Self.duration) | |
| .repeatForever(autoreverses: false) | |
| .delay(2.28) | |
| withAnimation(animation) { | |
| offset3 = geometry.size.width | |
| } | |
| } | |
| } | |
| } | |
| wall4 | |
| .mask(alignment: .topLeading) { | |
| GeometryReader { geometry in | |
| Image("maskie2") | |
| .offset(x: offset4) | |
| .onAppear { | |
| let animation = Animation | |
| .linear(duration: Self.duration) | |
| .repeatForever(autoreverses: false) | |
| .delay(3.4) | |
| withAnimation(animation) { | |
| offset4 = geometry.size.width | |
| } | |
| } | |
| } | |
| } | |
| wall5 | |
| .mask(alignment: .topLeading) { | |
| GeometryReader { geometry in | |
| Image("maskie2") | |
| .offset(x: offset5) | |
| .onAppear { | |
| let animation = Animation | |
| .linear(duration: Self.duration) | |
| .repeatForever(autoreverses: false) | |
| .delay(4.5) | |
| withAnimation(animation) { | |
| offset5 = geometry.size.width | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| var wall1: some View { | |
| Image("wall1") | |
| .frame(width: 300, height: 200) | |
| .cornerRadius(20.0) | |
| .clipped() | |
| } | |
| var wall2: some View { | |
| Image("wall2") | |
| .frame(width: 300, height: 200) | |
| .cornerRadius(20.0) | |
| .clipped() | |
| } | |
| var wall3: some View { | |
| Image("wall3") | |
| .frame(width: 300, height: 200) | |
| .cornerRadius(20.0) | |
| .clipped() | |
| } | |
| var wall4: some View { | |
| Image("wall4") | |
| .frame(width: 300, height: 200) | |
| .cornerRadius(20.0) | |
| .clipped() | |
| } | |
| var wall5: some View { | |
| Image("wall5") | |
| .frame(width: 300, height: 200) | |
| .cornerRadius(20.0) | |
| .clipped() | |
| } | |
| } | |
| struct ContentView_Previews: PreviewProvider { | |
| static var previews: some View { | |
| ContentView() | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assets/images: https://imgur.com/a/vgTfDbr