mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-13 09:07:29 +02:00
Add a scroll to top button siteConfig option (#723)
This commit is contained in:
parent
a43cc597f8
commit
aee255219b
4 changed files with 40 additions and 0 deletions
|
@ -149,6 +149,33 @@ class Head extends React.Component {
|
|||
);
|
||||
})}
|
||||
|
||||
{this.props.config.scrollToTop && (
|
||||
<script
|
||||
src={
|
||||
'https://unpkg.com/vanilla-back-to-top@7.1.14/dist/vanilla-back-to-top.min.js'
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{this.props.config.scrollToTop && (
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
document.addEventListener("DOMContentLoaded", function(){
|
||||
addBackToTop(
|
||||
${JSON.stringify(
|
||||
Object.assign(
|
||||
{},
|
||||
{zIndex: 100},
|
||||
this.props.config.scrollToTopOptions
|
||||
)
|
||||
)}
|
||||
)
|
||||
});
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Site defined code. Keep these at the end to avoid overriding. */}
|
||||
<link
|
||||
rel="stylesheet"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue