This file contains 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 { | |
Component, | |
component$, | |
useStore, | |
PublicProps, | |
useTask$, | |
noSerialize, | |
NoSerialize, | |
} from "@builder.io/qwik"; | |
import { Meta, StoryObj } from "storybook-framework-qwik/*"; |
This file contains 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
struct ListTransitionView: View { | |
@State var pickedNumber: Int? | |
@Namespace var namespace | |
var body: some View { | |
VStack { | |
if pickedNumber == nil { | |
VStack(spacing: 15) { | |
ForEach(0..<3) { number in | |
Button("Hello world \(number)") { |
This file contains 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
@objc func handlePan(panGesture: UIPanGestureRecognizer) { | |
guard let view = view as? SCNView else { return } | |
let location = panGesture.location(in: self.view) | |
switch panGesture.state { | |
case .began: | |
// existing logic from previous approach. Keep this. | |
guard let hitNodeResult = view.hitTest(location, options: nil).first else { return } | |
panStartZ = CGFloat(view.projectPoint(lastPanLocation!).z) | |
// lastPanLocation is new | |
lastPanLocation = hitNodeResult.worldCoordinates |
This file contains 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
@objc func handlePan(panGesture: UIPanGestureRecognizer) { | |
guard let view = view as? SCNView else { return } | |
switch panGesture.state { | |
case .began: | |
let location = panGesture.location(in: self.view) | |
guard let hitNodeResult = view.hitTest(location, options: nil).first else { return } | |
panStartZ = CGFloat(view.projectPoint(lastPanLocation!).z) | |
lastPanLocation = hitNodeResult.worldCoordinates | |
draggingNode = hitNodeResult.node | |
case .changed: |
This file contains 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
@objc func handlePan(panGesture: UIPanGestureRecognizer) { | |
guard let view = view as? SCNView else { return } | |
let location = panGesture.location(in: self.view) | |
switch panGesture.state { | |
case .began: | |
guard let hitNodeResult = view.hitTest(location, options: nil).first else { return } | |
// panStartZ and draggingNode should be defined in the containing class | |
panStartZ = CGFloat(view.projectPoint(lastPanLocation!).z) | |
draggingNode = hitNodeResult.node | |
case .changed: |
This file contains 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
// Create the box: | |
let cube = SCNBox(width: 10, height: 10, length: 10, chamferRadius: 1.0) | |
let cubeNode = SCNNode(geometry: cube) | |
scene.rootNode.addChildNode(cubeNode) | |
// Create the gesture recognizer: | |
let panRecognizer = UIPanGestureRecognizer(target: self, action: #selector(handlePan(panGesture:))) | |
view.addGestureRecognizer(panRecognizer) |