このコミットが含まれているのは:
@@ -1,4 +1,4 @@
|
|||||||
import { motion, useMotionTemplate, useMotionValue } from 'framer-motion'
|
import { animate, motion, useMotionTemplate, useMotionValue } from 'framer-motion'
|
||||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { Helmet } from 'react-helmet-async'
|
import { Helmet } from 'react-helmet-async'
|
||||||
@@ -2660,6 +2660,21 @@ const GekanatorBackdrop: FC<{
|
|||||||
winningRunTargetPost = null,
|
winningRunTargetPost = null,
|
||||||
winningRunQuestionCount = 0,
|
winningRunQuestionCount = 0,
|
||||||
}) => {
|
}) => {
|
||||||
|
const guessFocusOffset = useMemo (() => {
|
||||||
|
const focusTiles = [
|
||||||
|
{ x: 'calc(max(100vw, 100vh) * 0.5)',
|
||||||
|
y: 'calc(max(100vw, 100vh) * 0.5)' },
|
||||||
|
{ x: 'calc(max(100vw, 100vh) * -0.5)',
|
||||||
|
y: 'calc(max(100vw, 100vh) * 0.5)' },
|
||||||
|
{ x: 'calc(max(100vw, 100vh) * 0.5)',
|
||||||
|
y: 'calc(max(100vw, 100vh) * -0.5)' },
|
||||||
|
{ x: 'calc(max(100vw, 100vh) * -0.5)',
|
||||||
|
y: 'calc(max(100vw, 100vh) * -0.5)' }]
|
||||||
|
|
||||||
|
return (focusTiles[Math.abs (hashString (`${ visualSeed }:guess-focus`)) % focusTiles.length]
|
||||||
|
?? focusTiles[0])
|
||||||
|
}, [visualSeed])
|
||||||
|
|
||||||
const directions = useMemo (
|
const directions = useMemo (
|
||||||
() => [
|
() => [
|
||||||
{ x: 0, y: -33.333333 },
|
{ x: 0, y: -33.333333 },
|
||||||
@@ -2686,6 +2701,7 @@ const GekanatorBackdrop: FC<{
|
|||||||
: isWinningRunBackdrop
|
: isWinningRunBackdrop
|
||||||
? 'winning_run'
|
? 'winning_run'
|
||||||
: 'normal'
|
: 'normal'
|
||||||
|
|
||||||
const normalVisiblePosts = useMemo (
|
const normalVisiblePosts = useMemo (
|
||||||
() => posts
|
() => posts
|
||||||
.filter (post => Boolean (backgroundThumbnailUrl (post)))
|
.filter (post => Boolean (backgroundThumbnailUrl (post)))
|
||||||
@@ -2694,27 +2710,35 @@ const GekanatorBackdrop: FC<{
|
|||||||
- hashString (`${ visualSeed }:${ right.id }`))
|
- hashString (`${ visualSeed }:${ right.id }`))
|
||||||
.slice (0, motionMode === 'calm' ? 24 : 36),
|
.slice (0, motionMode === 'calm' ? 24 : 36),
|
||||||
[posts, visualSeed, motionMode])
|
[posts, visualSeed, motionMode])
|
||||||
const settingsForMode = useCallback ((
|
|
||||||
mode: 'normal' | 'winning_run' | 'guess',
|
const settingsForMode = useCallback (
|
||||||
): { columns: number; rows: number; opacity: number } => {
|
(
|
||||||
if (mode === 'winning_run')
|
mode: 'normal' | 'winning_run' | 'guess',
|
||||||
return { columns: 8, rows: 8, opacity: motionMode === 'calm' ? .18 : .24 }
|
): { columns: number; rows: number; opacity: number } => {
|
||||||
if (mode === 'guess')
|
if (mode === 'winning_run' || mode === 'guess')
|
||||||
return { columns: 1, rows: 1, opacity: motionMode === 'calm' ? .18 : .24 }
|
return { columns: 8, rows: 8, opacity: motionMode === 'calm' ? .18 : .24 }
|
||||||
return motionMode === 'calm'
|
|
||||||
? { columns: 7, rows: 7, opacity: .14 }
|
return motionMode === 'calm'
|
||||||
: { columns: 10, rows: 10, opacity: .2 }
|
? { columns: 7, rows: 7, opacity: .14 }
|
||||||
}, [motionMode])
|
: { columns: 10, rows: 10, opacity: .2 }
|
||||||
const scaleForMode = useCallback ((
|
},
|
||||||
mode: 'normal' | 'winning_run' | 'guess',
|
[motionMode])
|
||||||
displayedWinningCount: number,
|
|
||||||
): number => {
|
const scaleForMode = useCallback (
|
||||||
if (mode === 'winning_run')
|
(
|
||||||
return [1, 8 / 6, 8 / 4, 8 / 2][
|
mode: 'normal' | 'winning_run' | 'guess',
|
||||||
Math.max (0, Math.min (3, displayedWinningCount))]
|
displayedWinningCount: number,
|
||||||
?? 1
|
): number => {
|
||||||
return 1
|
if (mode === 'guess')
|
||||||
}, [])
|
return 8
|
||||||
|
|
||||||
|
if (mode === 'winning_run')
|
||||||
|
return [1, 8 / 6, 8 / 4, 8 / 2][Math.max (0, Math.min (3, displayedWinningCount))] ?? 1
|
||||||
|
|
||||||
|
return 1
|
||||||
|
},
|
||||||
|
[])
|
||||||
|
|
||||||
const postsForMode = useCallback ((
|
const postsForMode = useCallback ((
|
||||||
mode: 'normal' | 'winning_run' | 'guess',
|
mode: 'normal' | 'winning_run' | 'guess',
|
||||||
): Post[] => {
|
): Post[] => {
|
||||||
@@ -2724,6 +2748,7 @@ const GekanatorBackdrop: FC<{
|
|||||||
return [winningRunTargetPost]
|
return [winningRunTargetPost]
|
||||||
return normalVisiblePosts
|
return normalVisiblePosts
|
||||||
}, [displayedGuess, winningRunTargetPost, normalVisiblePosts])
|
}, [displayedGuess, winningRunTargetPost, normalVisiblePosts])
|
||||||
|
|
||||||
const thumbnailsForMode = useCallback ((
|
const thumbnailsForMode = useCallback ((
|
||||||
mode: 'normal' | 'winning_run' | 'guess',
|
mode: 'normal' | 'winning_run' | 'guess',
|
||||||
count: number,
|
count: number,
|
||||||
@@ -2737,16 +2762,20 @@ const GekanatorBackdrop: FC<{
|
|||||||
return backgroundThumbnailUrl (post) ?? null
|
return backgroundThumbnailUrl (post) ?? null
|
||||||
}).filter ((thumbnail): thumbnail is string => Boolean (thumbnail))
|
}).filter ((thumbnail): thumbnail is string => Boolean (thumbnail))
|
||||||
}, [postsForMode])
|
}, [postsForMode])
|
||||||
|
|
||||||
const targetSettings = settingsForMode (backdropMode)
|
const targetSettings = settingsForMode (backdropMode)
|
||||||
const targetTileCount = targetSettings.columns * targetSettings.rows
|
const targetTileCount = targetSettings.columns * targetSettings.rows
|
||||||
|
|
||||||
const nextThumbnails = useMemo (
|
const nextThumbnails = useMemo (
|
||||||
() => thumbnailsForMode (backdropMode, targetTileCount),
|
() => thumbnailsForMode (backdropMode, targetTileCount),
|
||||||
[backdropMode, targetTileCount, thumbnailsForMode])
|
[backdropMode, targetTileCount, thumbnailsForMode])
|
||||||
|
|
||||||
const nextDirection = useMemo (
|
const nextDirection = useMemo (
|
||||||
() => directions[
|
() => directions[
|
||||||
Math.abs (hashString (`${ visualSeed }:direction`)) % directions.length]
|
Math.abs (hashString (`${ visualSeed }:direction`)) % directions.length]
|
||||||
?? directions[0],
|
?? directions[0],
|
||||||
[visualSeed, directions])
|
[visualSeed, directions])
|
||||||
|
|
||||||
const marqueeDuration =
|
const marqueeDuration =
|
||||||
backdropMode === 'winning_run'
|
backdropMode === 'winning_run'
|
||||||
? motionMode === 'calm' ? 28 : 20
|
? motionMode === 'calm' ? 28 : 20
|
||||||
@@ -2773,12 +2802,29 @@ const GekanatorBackdrop: FC<{
|
|||||||
const renderedSettings = settingsForMode (displayedBackdropMode)
|
const renderedSettings = settingsForMode (displayedBackdropMode)
|
||||||
const renderedTileCount =
|
const renderedTileCount =
|
||||||
renderedSettings.columns * renderedSettings.rows
|
renderedSettings.columns * renderedSettings.rows
|
||||||
const renderedScale = scaleForMode (
|
const renderedScale = scaleForMode (displayedBackdropMode, displayedWinningRunCount)
|
||||||
displayedBackdropMode,
|
|
||||||
displayedWinningRunCount)
|
|
||||||
const isGuessPresentation =
|
const isGuessPresentation =
|
||||||
backdropMode === 'guess' || displayedBackdropMode === 'guess'
|
backdropMode === 'guess' || displayedBackdropMode === 'guess'
|
||||||
|
|
||||||
|
useEffect (() => {
|
||||||
|
if (motionMode === 'off')
|
||||||
|
return
|
||||||
|
|
||||||
|
if (!(isGuessPresentation))
|
||||||
|
return
|
||||||
|
|
||||||
|
const duration = motionMode === 'calm' ? .95 : .75
|
||||||
|
const ease = [0.16, 1, 0.3, 1] as const
|
||||||
|
|
||||||
|
const controls = [
|
||||||
|
animate (x, 0, { duration, ease }),
|
||||||
|
animate (y, 0, { duration, ease })]
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
controls.forEach (control => control.stop ())
|
||||||
|
}
|
||||||
|
}, [isGuessPresentation, motionMode, visualSeed, x, y])
|
||||||
|
|
||||||
useEffect (() => {
|
useEffect (() => {
|
||||||
activeDirectionRef.current = activeDirection
|
activeDirectionRef.current = activeDirection
|
||||||
}, [activeDirection])
|
}, [activeDirection])
|
||||||
@@ -2790,15 +2836,15 @@ const GekanatorBackdrop: FC<{
|
|||||||
return wrapped > cell / 2 ? wrapped - cell : wrapped
|
return wrapped > cell / 2 ? wrapped - cell : wrapped
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (motionMode === 'off' || nextThumbnails.length === 0)
|
||||||
motionMode === 'off'
|
{
|
||||||
|| isGuessPresentation
|
x.set (0)
|
||||||
|| nextThumbnails.length === 0
|
y.set (0)
|
||||||
) {
|
return
|
||||||
x.set (0)
|
}
|
||||||
y.set (0)
|
|
||||||
|
if (isGuessPresentation)
|
||||||
return
|
return
|
||||||
}
|
|
||||||
|
|
||||||
const speed = 33.333333 / marqueeDuration
|
const speed = 33.333333 / marqueeDuration
|
||||||
let animationFrame: number
|
let animationFrame: number
|
||||||
@@ -2843,8 +2889,6 @@ const GekanatorBackdrop: FC<{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (backdropMode === 'guess' && guessThumbnail) {
|
if (backdropMode === 'guess' && guessThumbnail) {
|
||||||
x.set (0)
|
|
||||||
y.set (0)
|
|
||||||
setIsFlippingTiles (false)
|
setIsFlippingTiles (false)
|
||||||
setDisplayedBackdropMode ('guess')
|
setDisplayedBackdropMode ('guess')
|
||||||
setDisplayedWinningRunCount (winningRunQuestionCount)
|
setDisplayedWinningRunCount (winningRunQuestionCount)
|
||||||
@@ -2942,18 +2986,19 @@ const GekanatorBackdrop: FC<{
|
|||||||
<motion.div
|
<motion.div
|
||||||
className="relative shrink-0"
|
className="relative shrink-0"
|
||||||
style={{
|
style={{
|
||||||
transform: isGuessPresentation ? undefined : marqueeTransform,
|
transform: marqueeTransform,
|
||||||
width: 'calc(max(100vw, 100vh) * 3)',
|
width: 'calc(max(100vw, 100vh) * 3)',
|
||||||
height: 'calc(max(100vw, 100vh) * 3)' }}>
|
height: 'calc(max(100vw, 100vh) * 3)' }}>
|
||||||
<motion.div
|
<motion.div
|
||||||
className="relative h-full w-full"
|
className="relative h-full w-full"
|
||||||
animate={{ scale: renderedScale }}
|
animate={{ scale: renderedScale,
|
||||||
transition={displayedBackdropMode === 'winning_run'
|
x: displayedBackdropMode === 'guess' ? guessFocusOffset.x : '0%',
|
||||||
|| displayedBackdropMode === 'guess'
|
y: displayedBackdropMode === 'guess' ? guessFocusOffset.y : '0%' }}
|
||||||
? {
|
transition={(displayedBackdropMode === 'winning_run'
|
||||||
duration: motionMode === 'calm' ? .75 : .55,
|
|| displayedBackdropMode === 'guess')
|
||||||
ease: 'easeOut' }
|
? { duration: motionMode === 'calm' ? .95 : .75,
|
||||||
: { duration: .2 }}>
|
ease: [.16, 1, .3, 1] }
|
||||||
|
: { duration: .2 }}>
|
||||||
{Array.from ({ length: 9 }, (_, duplicate) => {
|
{Array.from ({ length: 9 }, (_, duplicate) => {
|
||||||
const column = duplicate % 3
|
const column = duplicate % 3
|
||||||
const row = Math.floor (duplicate / 3)
|
const row = Math.floor (duplicate / 3)
|
||||||
|
|||||||
新しい課題から参照
ユーザをブロックする