Skip to content

Commit

Permalink
Allow metronome sound to continue to play from collapsed sidebar
Browse files Browse the repository at this point in the history
This makes it match the behavior of audio files playing from a collapsed
sidebar. Closes #2.
  • Loading branch information
curtgrimes committed Dec 23, 2021
1 parent 076a693 commit 549dcf3
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/hooks/useParentMarkdownWrapperVisibilityWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ export function useParentMarkdownWrapperVisibilityWatcher(
elementRef.value.closest(".markdown-reading-view")
: null;

// We want to consider it still visible if it's
// in a sidebar to match the behavior of audio players.
const isInSidebar = () =>
markdownWrapperParent.closest(
".mod-left-split, .mod-right-split"
) !== null;

const { stop } = useIntersectionObserver(
markdownWrapperParent as MaybeElementRef,
(entries) =>
(isVisible.value = entries.some(
(entry) => entry.isIntersecting
))
(isVisible.value =
entries.some((entry) => entry.isIntersecting) ||
isInSidebar())
);

stopFunction.value = stop;
Expand Down

0 comments on commit 549dcf3

Please sign in to comment.