-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
73 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment' | ||
|
||
const instantiateStickyMedia = () => { | ||
new StickyMedia() | ||
} | ||
|
||
// On route change | ||
export function onRouteDidUpdate({ location, previousLocation }) { | ||
// Don't execute if we are still on the same page; the lifecycle may be fired | ||
// because the hash changes (e.g. when navigating between headings) | ||
if (location.pathname === previousLocation?.pathname) return | ||
setTimeout(instantiateStickyMedia, 100) | ||
} | ||
|
||
// On load | ||
if (ExecutionEnvironment.canUseDOM) { | ||
window.addEventListener('load', () => { | ||
// Remove stale video info | ||
localStorage.removeItem('videoID') | ||
localStorage.removeItem('videoModalFlag') | ||
localStorage.removeItem('videoModalTime') | ||
localStorage.setItem('videoModalView', 'fullscreen-mode') | ||
|
||
setTimeout(instantiateStickyMedia, 100) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
versioned_docs/version-0.1/tutorial-extras/sticky-media.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
sidebar_position: 3 | ||
--- | ||
|
||
# Sticky media | ||
|
||
You may add a sticky video by giving `sticky-popup` class to an `a` tag. | ||
|
||
```html | ||
<!-- md content above --> | ||
|
||
<a | ||
// highlight-next-line | ||
class="sticky-popup" | ||
target="_blank" | ||
href="https://www.youtube.com/watch?v=G1OM2L7XK5Y" | ||
>Sticky video</a | ||
> | ||
|
||
<!-- md content below --> | ||
``` | ||
|
||
## Try it! | ||
|
||
<a | ||
class="sticky-popup" | ||
target="_blank" | ||
href="https://www.youtube.com/watch?v=G1OM2L7XK5Y" | ||
data-video-id="G1OM2L7XK5Y" | ||
>Sticky video</a> |