Skip to content

Commit

Permalink
feat: orientation sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
gitchaell committed Apr 25, 2024
1 parent eff9ca0 commit 457f749
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/components/blocks/Title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,10 @@ export const Title = ({ fullname }: { fullname: string }) => {
const handleOrientationChange = (event: DeviceOrientationEvent) => {
if (!titleRef.current) return

let [x, y] = [event.beta!, event.gamma!] // [-180,180) [-90,90)
let [x, y] = [event.gamma!, event.beta!]

x = x > 90 ? 90 : x
x = x < -90 ? -90 : x
y = y > 90 ? 90 : y
y = y < -90 ? -90 : y

x += 90
y += 90
x = Math.min(90, Math.max(-90, x)) + 90
y = Math.min(180, Math.max(-180, y)) + 90

const maxX = document.body.clientWidth - titleRef.current.clientWidth
const maxY = document.body.clientHeight - titleRef.current.clientHeight
Expand Down

0 comments on commit 457f749

Please sign in to comment.