-
Notifications
You must be signed in to change notification settings - Fork 0
chore(release): bump mobile version to 1.1.10 and update changelog #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| import type { EclipseKindAtLocation } from "@eclipse-timer/shared"; | ||
|
|
||
| export const PREVIEW_SUN_RADIUS = 72; | ||
| export const PREVIEW_STAGE_SIZE = 300; | ||
|
|
||
| export type PreviewMotionContacts = { | ||
| c1?: number; | ||
| c2?: number; | ||
| max?: number; | ||
| c3?: number; | ||
| c4?: number; | ||
| }; | ||
|
|
||
| export type PreviewMoonGeometry = { | ||
| moonRadius: number; | ||
| moonClosestOffset: number; | ||
| moonCenterX: number; | ||
| moonCenterY: number; | ||
| moonOffsetX: number; | ||
| moonTravelHalfSpan: number; | ||
| }; | ||
|
|
||
| function clamp01(v: number) { | ||
| return Math.max(0, Math.min(1, v)); | ||
| } | ||
|
|
||
| export function determineMoonRadius(kindAtLocation: EclipseKindAtLocation) { | ||
| if (kindAtLocation === "annular") return 58; | ||
| if (kindAtLocation === "total") return 76; | ||
| if (kindAtLocation === "partial") return 68; | ||
| return 66; | ||
| } | ||
|
|
||
| export function determineApproachOffset( | ||
| kindAtLocation: EclipseKindAtLocation, | ||
| magnitude: number | undefined, | ||
| moonRadius: number, | ||
| sunRadius = PREVIEW_SUN_RADIUS, | ||
| ) { | ||
| if (kindAtLocation === "none") { | ||
| return sunRadius + moonRadius + 14; | ||
| } | ||
|
|
||
| if (kindAtLocation === "partial") { | ||
| const safeMag = | ||
| typeof magnitude === "number" && Number.isFinite(magnitude) ? clamp01(magnitude) : 0.6; | ||
| return (1 - safeMag) * (sunRadius + moonRadius - 6); | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| function buildMotionAnchors( | ||
| contacts: PreviewMotionContacts, | ||
| sunRadius: number, | ||
| moonRadius: number, | ||
| ): Array<{ progress: number; offsetX: number }> { | ||
| const externalTouchOffset = sunRadius + moonRadius; | ||
| const internalTouchOffset = Math.abs(sunRadius - moonRadius); | ||
|
|
||
| const anchors: Array<{ progress: number; offsetX: number }> = [ | ||
| { progress: 0, offsetX: -externalTouchOffset }, | ||
| { progress: 1, offsetX: externalTouchOffset }, | ||
| ]; | ||
|
|
||
| const maybePush = (progress: number | undefined, offsetX: number) => { | ||
| if (typeof progress !== "number" || !Number.isFinite(progress)) return; | ||
| anchors.push({ progress: clamp01(progress), offsetX }); | ||
| }; | ||
|
|
||
| maybePush(contacts.c1, -externalTouchOffset); | ||
| maybePush(contacts.c2, -internalTouchOffset); | ||
| maybePush(contacts.max, 0); | ||
| maybePush(contacts.c3, internalTouchOffset); | ||
| maybePush(contacts.c4, externalTouchOffset); | ||
|
|
||
| return anchors.sort((a, b) => a.progress - b.progress); | ||
| } | ||
|
|
||
| function interpolateOffsetX( | ||
| progress: number, | ||
| anchors: Array<{ progress: number; offsetX: number }>, | ||
| ) { | ||
| const clampedProgress = clamp01(progress); | ||
| const first = anchors[0]; | ||
| const last = anchors[anchors.length - 1]; | ||
| if (!first || !last) return 0; | ||
| if (clampedProgress <= first.progress) return first.offsetX; | ||
| if (clampedProgress >= last.progress) return last.offsetX; | ||
|
|
||
| for (let idx = 1; idx < anchors.length; idx += 1) { | ||
| const prev = anchors[idx - 1]; | ||
| const next = anchors[idx]; | ||
| if (!prev || !next) continue; | ||
| if (clampedProgress > next.progress) continue; | ||
| const span = next.progress - prev.progress; | ||
| if (span <= 0) return next.offsetX; | ||
| const segmentProgress = (clampedProgress - prev.progress) / span; | ||
| return prev.offsetX + (next.offsetX - prev.offsetX) * segmentProgress; | ||
| } | ||
|
|
||
| return last.offsetX; | ||
| } | ||
|
|
||
| export function calculatePreviewMoonGeometry(params: { | ||
| progress: number; | ||
| kindAtLocation: EclipseKindAtLocation; | ||
| magnitude?: number; | ||
| contacts?: PreviewMotionContacts; | ||
| stageSize?: number; | ||
| sunRadius?: number; | ||
| }): PreviewMoonGeometry { | ||
| const stageSize = params.stageSize ?? PREVIEW_STAGE_SIZE; | ||
| const sunRadius = params.sunRadius ?? PREVIEW_SUN_RADIUS; | ||
| const moonRadius = determineMoonRadius(params.kindAtLocation); | ||
| const moonClosestOffset = determineApproachOffset( | ||
| params.kindAtLocation, | ||
| params.magnitude, | ||
| moonRadius, | ||
| sunRadius, | ||
| ); | ||
|
|
||
| const anchors = buildMotionAnchors(params.contacts ?? {}, sunRadius, moonRadius); | ||
| const moonOffsetX = interpolateOffsetX(params.progress, anchors); | ||
| const moonCenterX = stageSize / 2 + moonOffsetX; | ||
| const moonCenterY = stageSize / 2 + moonClosestOffset; | ||
|
|
||
| return { | ||
| moonRadius, | ||
| moonClosestOffset, | ||
| moonCenterX, | ||
| moonCenterY, | ||
| moonOffsetX, | ||
| moonTravelHalfSpan: sunRadius + moonRadius, | ||
| }; | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { calculatePreviewMoonGeometry, PREVIEW_SUN_RADIUS } from "../src/utils/previewGeometry"; | ||
|
|
||
| describe("preview moon geometry", () => { | ||
| it("places C1 at exact outer tangency", () => { | ||
| const geometry = calculatePreviewMoonGeometry({ | ||
| progress: 0, | ||
| kindAtLocation: "total", | ||
| contacts: { c1: 0, c2: 0.25, max: 0.5, c3: 0.75, c4: 1 }, | ||
| }); | ||
|
|
||
| const centerDistance = Math.abs(geometry.moonCenterX - 150); | ||
| expect(centerDistance).toBeCloseTo(PREVIEW_SUN_RADIUS + geometry.moonRadius, 6); | ||
| }); | ||
|
|
||
| it("places C2 at exact inner tangency and max at center", () => { | ||
| const c2Geometry = calculatePreviewMoonGeometry({ | ||
| progress: 0.25, | ||
| kindAtLocation: "total", | ||
| contacts: { c1: 0, c2: 0.25, max: 0.5, c3: 0.75, c4: 1 }, | ||
| }); | ||
| const maxGeometry = calculatePreviewMoonGeometry({ | ||
| progress: 0.5, | ||
| kindAtLocation: "total", | ||
| contacts: { c1: 0, c2: 0.25, max: 0.5, c3: 0.75, c4: 1 }, | ||
| }); | ||
|
|
||
| const c2Distance = Math.abs(c2Geometry.moonCenterX - 150); | ||
| expect(c2Distance).toBeCloseTo(Math.abs(PREVIEW_SUN_RADIUS - c2Geometry.moonRadius), 6); | ||
| expect(maxGeometry.moonCenterX).toBeCloseTo(150, 6); | ||
| }); | ||
|
|
||
| it("keeps C3 as inner tangency and only exposes sun after C3", () => { | ||
| const c3Geometry = calculatePreviewMoonGeometry({ | ||
| progress: 0.75, | ||
| kindAtLocation: "total", | ||
| contacts: { c1: 0, c2: 0.25, max: 0.5, c3: 0.75, c4: 1 }, | ||
| }); | ||
| const postC3Geometry = calculatePreviewMoonGeometry({ | ||
| progress: 0.8, | ||
| kindAtLocation: "total", | ||
| contacts: { c1: 0, c2: 0.25, max: 0.5, c3: 0.75, c4: 1 }, | ||
| }); | ||
|
|
||
| const c3Distance = Math.abs(c3Geometry.moonCenterX - 150); | ||
| const postC3Distance = Math.abs(postC3Geometry.moonCenterX - 150); | ||
|
|
||
| expect(c3Distance).toBeCloseTo(Math.abs(PREVIEW_SUN_RADIUS - c3Geometry.moonRadius), 6); | ||
| expect(postC3Distance).toBeGreaterThan(c3Distance); | ||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EclipsePreviewScreencomputes timeline start asc1 ?? firstMs, so payloads withoutc1Utccan legitimately havec2/maxat progress0. This hardcoded start anchor forces progress0to outer tangency, andinterpolateOffsetXreturns that value before considering the real first contact, so the moon is drawn in the wrong phase exactly at the first timestamp (for example, showing C2 as outer tangency instead of inner tangency).Useful? React with 👍 / 👎.