From 2c47f52fce011a2473b04818fb666d9168d5dff2 Mon Sep 17 00:00:00 2001 From: Victor Turgeon <76506447+Medenos@users.noreply.github.com> Date: Sun, 30 Oct 2022 11:42:35 -0700 Subject: [PATCH] chargement async des items dans "morceaux" se fait sur le scroll down (pu besoin de boutton) --- .../grosses-mitaines-ui/src/pages/Morceaux.js | 17 ++++++--- .../src/stylesheets/site.css | 35 +++++++++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/GrossesMitaines/grosses-mitaines-ui/src/pages/Morceaux.js b/GrossesMitaines/grosses-mitaines-ui/src/pages/Morceaux.js index e54d1e6..243f016 100644 --- a/GrossesMitaines/grosses-mitaines-ui/src/pages/Morceaux.js +++ b/GrossesMitaines/grosses-mitaines-ui/src/pages/Morceaux.js @@ -94,29 +94,38 @@ const Morceaux = () => { const json = await response.json(); setProducts([...json]); setIsLoading(false); + } + const handleScroll = async (e) => { + const target = e.target; + if (!isLoading && !isSearch) { + if (target.scrollTop + target.clientHeight + 300 >= target.scrollHeight) { + await handleNextItems(); + } + } } return ( -