Skip to content

Commit

Permalink
citeproc-rs conversion: Reimplement hide welcome
Browse files Browse the repository at this point in the history
  • Loading branch information
tnajdek committed Jun 8, 2021
1 parent a7021ef commit ee3fab1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/js/components/container.jsx
Expand Up @@ -670,6 +670,17 @@ const BibWebContainer = props => {
}
}, [citationStyle, config, handleError, history, title]);

const handleScroll = useCallback(() => {
if(!messages.find(m => m.kind === 'WELCOME_MESSAGE')) {
return;
}
const target = document.querySelector('.zbib-illustration');
const isScrolledToIllustration = window.pageYOffset > target.offsetTop;
if(isScrolledToIllustration) {
setMessages(messages.filter(m => m.kind !== 'WELCOME_MESSAGE'));
}
}, [messages]);

const handleStyleInstallerDelete = useCallback((deleteStyleMeta) => {
setCitationStyles(citationStyles.filter(cs => cs.name !== deleteStyleMeta.name ));
}, [citationStyles]);
Expand Down Expand Up @@ -938,6 +949,11 @@ const BibWebContainer = props => {
return () => document.removeEventListener('visibilitychange', handleVisibilityChange);
}, [handleVisibilityChange]);

useEffect(() => {
document.addEventListener('scroll', handleScroll);
return () => document.removeEventListener('scroll', handleScroll);
}, [handleScroll]);

useEffect(() => {
document.addEventListener('copy', handleCopyToClipboard, true);

Expand Down

0 comments on commit ee3fab1

Please sign in to comment.