Re-add particles to homepage

This commit is contained in:
Kevin Kandlbinder 2021-11-07 22:54:49 +00:00 committed by GitHub
parent 4688007416
commit 75f95fe96e
2 changed files with 22 additions and 0 deletions

View file

@ -20,6 +20,7 @@ import {
Phone,
} from "lucide-react";
import { useTranslation } from "react-i18next";
import * as particleConfig from "./index.particles.json";
export const query = graphql`
query GetMetaAndProjects($language: String) {
@ -46,6 +47,19 @@ export const query = graphql`
}
`;
const loadTsParticles = async () => {
import("tsparticles").then(({ tsParticles }) => {
tsParticles.load("particle-container", particleConfig).then(() => {
anime({
targets: ["#particle-container > canvas"],
opacity: [0, 1],
duration: 10000,
easing: "easeInOutCirc",
});
});
});
};
const IndexPage = (props) => {
const { t } = useTranslation();
@ -77,6 +91,10 @@ const IndexPage = (props) => {
duration: 250,
easing: "easeInOutCirc",
});
// eslint-disable-next-line no-undef
if (typeof window !== "undefined")
window.setTimeout(loadTsParticles, 1000);
}, []);
let meta = props.data.site.siteMetadata;

View file

@ -20,6 +20,10 @@
padding: 0;
top: 0;
left: 0;
> canvas {
opacity: 0;
}
}
.spacer {