Skip to content
This repository was archived by the owner on Jan 27, 2025. It is now read-only.

Commit cb00259

Browse files
author
John Richard Chipps-Harding
authored
Disable Scroll (#10)
1 parent 79c4d59 commit cb00259

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ You can configure a few things by editing the file `src/config/index.tsx`.
2323
- `FILE_EXTENSION` - The filetypes supported. Default `png`.
2424
- `FILE_MIME` - The file mime type. Default `image/png`.
2525
- `SHOW_TITLE` - If the title should be overlaid. Default `false`.
26+
- `DISABLE_SCROLL` - Should the user be able to scroll? Default `true`.
2627
- `STACK_TRANSFORM` - How the stack should be positioned on the page. Default shown below.
2728

2829
```ts

src/config/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const RETRY_INTERVAL = 10 * 1000;
55
export const FILE_EXTENSION = "png";
66
export const FILE_MIME = "image/png";
77
export const SHOW_TITLE = false;
8+
export const DISABLE_SCROLL = true;
89

910
export const STACK_TRANSFORM = {
1011
x: "100%",

src/pages/index.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { useRef } from "react";
1+
import { useEffect, useRef } from "react";
22

33
import { useFullscreen } from "rooks";
44
import Head from "next/head";
55
import type { NextPage } from "next";
66

77
import useImages from "@/hooks/useImages";
8-
import { STACK_TRANSFORM } from "@/config";
8+
import { DISABLE_SCROLL, STACK_TRANSFORM } from "@/config";
99
import { Positioner } from "@/components/Positioner";
1010
import { ImageStack } from "@/components/ImageStack";
1111

@@ -15,6 +15,16 @@ const Home: NextPage = () => {
1515
const { toggleFullscreen } = useFullscreen({
1616
target: fullscreenContainerRef,
1717
});
18+
19+
useEffect(() => {
20+
if (!DISABLE_SCROLL) return;
21+
const old = document.body.style.overflow;
22+
document.body.style.overflow = "hidden";
23+
return () => {
24+
document.body.style.overflow = old;
25+
};
26+
}, []);
27+
1828
return (
1929
<>
2030
<Head>

src/styles/globals.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ html,
22
body {
33
padding: 0;
44
margin: 0;
5-
overflow: hidden;
65
}
76

87
body:fullscreen {

0 commit comments

Comments
 (0)