diff --git a/src/components/lazy-shazam.jsx b/src/components/lazy-shazam.jsx index 3eea4808..b50c46d3 100644 --- a/src/components/lazy-shazam.jsx +++ b/src/components/lazy-shazam.jsx @@ -30,7 +30,11 @@ export default function LazyShazam({ children }) { if (!containerRef.current) return; const rect = containerRef.current.getBoundingClientRect(); if (rect.bottom > TOP) { - setVisibleStart(true); + if (rect.top < window.innerHeight) { + setVisible(true); + } else { + setVisibleStart(true); + } } }, []); diff --git a/src/components/translation-block.jsx b/src/components/translation-block.jsx index 588ee1f9..828a0303 100644 --- a/src/components/translation-block.jsx +++ b/src/components/translation-block.jsx @@ -10,6 +10,7 @@ import localeCode2Text from '../utils/localeCode2Text'; import pmem from '../utils/pmem'; import Icon from './icon'; +import LazyShazam from './lazy-shazam'; import Loader from './loader'; const { PHANPY_LINGVA_INSTANCES } = import.meta.env; @@ -142,23 +143,21 @@ function TranslationBlock({ detectedLang !== targetLangText ) { return ( -
-
-
- - - {translatedContent} - -
+ +
+ + + {translatedContent} +
-
+ ); } return null;