Added drag to scroll container
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import type { NextPage } from 'next'
|
||||
import type {NextPage} from 'next'
|
||||
import Head from 'next/head'
|
||||
import {useGroups} from "../../components/contexts/GroupProvider";
|
||||
import {useFactories} from "../../src/hooks/useFactories";
|
||||
import {ProducingGraph} from "../../components/shared/ProducingGraph/ProducingGraph";
|
||||
import {useMemo} from "react";
|
||||
import {useEffect, useMemo} from "react";
|
||||
import {calculateInputs} from "../../src/calculateInputs";
|
||||
import {NodeOverview, OverviewGraphNode} from "../../components/visualize/NodeOverview/NodeOverview";
|
||||
import {fixedEncodeURIComponent} from "../../src/utils";
|
||||
import {ScrollContainer} from "../../components/shared/ScrollContainer/ScrollContainer";
|
||||
|
||||
const Page: NextPage = () => {
|
||||
const {
|
||||
@@ -18,6 +20,11 @@ const Page: NextPage = () => {
|
||||
findFactory
|
||||
} = useFactories()
|
||||
|
||||
useEffect(() => {
|
||||
document.body.classList.add("scroll");
|
||||
return () => document.body.classList.remove("scroll")
|
||||
}, []);
|
||||
|
||||
const producingNodes: OverviewGraphNode[] = useMemo(() => {
|
||||
return Object.values(groups).map(group => ({
|
||||
inputs: calculateInputs(
|
||||
@@ -42,20 +49,13 @@ const Page: NextPage = () => {
|
||||
<link rel="icon" href="/public/favicon.ico" />
|
||||
</Head>
|
||||
<main>
|
||||
<h1>Factorio Microservices</h1>
|
||||
<ProducingGraph nodes={producingNodes} inputs={baseFactories} childType={NodeOverview}></ProducingGraph>
|
||||
<ScrollContainer>
|
||||
<h1>Factorio Microservices</h1>
|
||||
<ProducingGraph nodes={producingNodes} inputs={baseFactories} childType={NodeOverview}/>
|
||||
</ScrollContainer>
|
||||
</main>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export async function getStaticProps() {
|
||||
return { props: { bodyClassName: 'scroll' } };
|
||||
}
|
||||
|
||||
function fixedEncodeURIComponent(str: string): string {
|
||||
return encodeURIComponent(str).replace(/[!'()*]/g, c => '%' + c.charCodeAt(0).toString(16));
|
||||
}
|
||||
|
||||
|
||||
export default Page
|
||||
|
||||
Reference in New Issue
Block a user