diff --git a/src/components/tile/LazyTile.js b/src/components/tile/LazyTile.js
new file mode 100644
index 0000000..54eaa06
--- /dev/null
+++ b/src/components/tile/LazyTile.js
@@ -0,0 +1,33 @@
+import React from "react";
+import { Box } from "theme-ui";
+import { useInView } from "react-intersection-observer";
+
+function LazyTile({ children }) {
+ const [ref, inView] = useInView({ triggerOnce: false });
+
+ const sx = inView
+ ? {}
+ : { width: "100%", height: "0", paddingTop: "100%", position: "relative" };
+
+ return (
+
+ {inView ? (
+ children
+ ) : (
+
+ )}
+
+ );
+}
+
+export default LazyTile;
diff --git a/src/components/tile/SortableTiles.js b/src/components/tile/SortableTiles.js
index 404102f..a42bfbd 100644
--- a/src/components/tile/SortableTiles.js
+++ b/src/components/tile/SortableTiles.js
@@ -5,6 +5,7 @@ import { moveGroupsInto } from "../../helpers/group";
import { keyBy } from "../../helpers/shared";
import SortableTile from "./SortableTile";
+import LazyTile from "./LazyTile";
import {
useTileDragId,
@@ -76,17 +77,18 @@ function SortableTiles({ renderTile, subgroup }) {
const disableTileGrouping =
disableGrouping || isDragging || hasSelectedContainerGroup;
return (
-
- {renderSortableGroup(group, selectedGroups)}
-
+
+
+ {renderSortableGroup(group, selectedGroups)}
+
+
);
});
}
diff --git a/src/components/tile/Tile.js b/src/components/tile/Tile.js
index 115a648..c550657 100644
--- a/src/components/tile/Tile.js
+++ b/src/components/tile/Tile.js
@@ -1,6 +1,5 @@
import React from "react";
import { Flex, IconButton, Box, Text, Badge } from "theme-ui";
-import { useInView } from "react-intersection-observer";
import EditTileIcon from "../../icons/EditTileIcon";
@@ -15,7 +14,6 @@ function Tile({
editTitle,
children,
}) {
- const [ref, inView] = useInView({ triggerOnce: true });
return (
- {inView && (
- <>
-
+ {children}
+
+
+
+ {title}
+
+
+
+
+ {badges.map((badge, i) => (
+
- {children}
-
-
+ ))}
+
+ {canEdit && (
+
+ {
+ e.preventDefault();
+ e.stopPropagation();
+ onEdit();
}}
- p={2}
+ bg="overlay"
+ sx={{ borderRadius: "50%" }}
+ m={2}
>
-
- {title}
-
-
-
-
- {badges.map((badge, i) => (
-
- {badge}
-
- ))}
-
- {canEdit && (
-
- {
- e.preventDefault();
- e.stopPropagation();
- onEdit();
- }}
- bg="overlay"
- sx={{ borderRadius: "50%" }}
- m={2}
- >
-
-
-
- )}
- >
+
+
+
)}
);