From 77cfa255274fdcdf822e836c7ea98e769bcb865d Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 6 Oct 2021 15:27:31 +0200 Subject: mobile --- src/views/Detail.js | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) (limited to 'src/views/Detail.js') diff --git a/src/views/Detail.js b/src/views/Detail.js index 772abb1..fb17c06 100644 --- a/src/views/Detail.js +++ b/src/views/Detail.js @@ -2,7 +2,7 @@ * Detail view, displaying text plus media */ -import React from "react"; +import React, { useRef, useEffect, useState, useCallback } from "react"; import Gallery from "./Gallery.js"; import Clocks from "./Clocks.js"; @@ -10,15 +10,45 @@ import Vimeo from "@u-wave/react-vimeo"; import { pad } from "../utils/index.js"; export default function Detail({ node, visible, onClose }) { + const ref = useRef(); + const contentRef = useRef(); + const [videoReady, setVideoReady] = useState(false); + + useEffect(() => { + if (!node) { + setVideoReady(false); + } + setTimeout(() => { + ref.current.scrollTo(0, -ref.current.scrollHeight); + if (contentRef.current) { + contentRef.current.scrollTo(0, -ref.current.scrollHeight); + } + }, 10); + }, [node]); + + const handleVideoReady = useCallback(() => { + if (node.data.object) { + setTimeout(() => { + setVideoReady(true); + }, 500); + } else { + setVideoReady(true); + } + }, [node]); + + const handleLoad = useCallback(() => { + ref.current.scrollTo(0, -ref.current.scrollHeight); + }); + if (!node) { - return
; + return
; } const { id, data } = node; const index = id + 1; return ( -
-
+
+
{pad(index)}
@@ -42,10 +72,10 @@ export default function Detail({ node, visible, onClose }) {
{index === 33 ? ( - + ) : data.type === "video" ? ( visible && ( -
+
) ) : ( - + )}
-- cgit v1.2.3-70-g09d2