Skip to content

Commit

Permalink
💫 Update: Exp - AdaptiveModal
Browse files Browse the repository at this point in the history
Summary: Update experiment/test - `swift-programmatic-modal/AdaptiveModal`.
  • Loading branch information
dominicstop committed Jun 18, 2023
1 parent da3199d commit 9fbd460
Showing 1 changed file with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ class AdaptiveModalManager: NSObject {
let origin = $0.computedRect.origin;
let coord = origin[keyPath: self.modalConfig.inputValueKeyForPoint];

return abs(coord - inputCoordAdj);
return abs(inputCoordAdj - coord);
};

let deltaSorted = delta.enumerated().sorted {
Expand All @@ -1128,6 +1128,23 @@ class AdaptiveModalManager: NSObject {
let interpolationPoint = interpolationSteps[closestInterpolationIndex];
let snapPointIndex = interpolationPoint.snapPointIndex;

let coords = self.interpolationSteps.map {
let origin = $0.computedRect.origin;
let coord = origin[keyPath: self.modalConfig.inputValueKeyForPoint];

return coord;
};

print(
"getClosestSnapPoint"
+ "\n - inputCoordAdj: \(inputCoordAdj)"
+ "\n - coords: \(coords)"
+ "\n - delta: \(delta)"
+ "\n - deltaSorted: \(deltaSorted)"
+ "\n - closestInterpolationIndex: \(closestInterpolationIndex)"
+ "\n"
);

return (
interpolationIndex: closestInterpolationIndex,
snapPointConfig: self.modalConfig.snapPoints[snapPointIndex],
Expand Down Expand Up @@ -1274,6 +1291,15 @@ class AdaptiveModalManager: NSObject {
y: gestureFinalPointRaw.y - (self.gestureOffset?.y ?? 0)
);

print(
"onDragPanGesture"
+ "\n - gesturePoint: \(gesturePoint)"
+ "\n - gestureVelocity: \(gestureVelocity)"
+ "\n - gestureFinalPointRaw: \(gestureFinalPointRaw)"
+ "\n - gestureFinalPoint: \(gestureFinalPoint)"
+ "\n"
);

self.snapToClosestSnapPoint(forPoint: gestureFinalPoint) {
self.notifyOnModalDidSnap();
};
Expand Down Expand Up @@ -1532,6 +1558,16 @@ class AdaptiveModalManager: NSObject {
let coord = point[keyPath: self.modalConfig.inputValueKeyForPoint];
let closestSnapPoint = self.getClosestSnapPoint(forCoord: coord);

print(
"snapToClosestSnapPoint"
+ "\n - coord: \(coord)"
+ "\n - closestSnapPoint.interpolationIndex: \(closestSnapPoint.interpolationIndex)"
+ "\n - closestSnapPoint.snapDistance: \(closestSnapPoint.snapDistance)"
+ "\n - closestSnapPoint.interpolationPoint: \(closestSnapPoint.interpolationPoint)"
+ "\n - closestSnapPoint.snapPointConfig: \(closestSnapPoint.snapPointConfig)"
+ "\n"
);

let nextInterpolationIndex =
self.adjustInterpolationIndex(for: closestSnapPoint.interpolationIndex);

Expand Down

0 comments on commit 9fbd460

Please sign in to comment.