Skip to content

Commit

Permalink
flash grid on image load
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleawayan committed Feb 12, 2021
1 parent aaa62da commit 891acac
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/AlbumArt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default function AlbumArt() {
const binaryStr = reader.result;
setImageBase64(binaryStr);
getResolution(binaryStr).then((res) => {
// note these "preset" zoom factors are for like regular sized photos, like 2:3 and stuff, but longer aspect ratios like 9:16 will be zoomed out
if (res.width < res.height) {
// potrait photos, found in my tests that a zoom factor of about 1.5 fills the square
setZoom(1.5);
Expand All @@ -61,7 +62,12 @@ export default function AlbumArt() {
accept: "image/jpeg, image/png",
});

console.log(zoom);
const flashGrid = () => {
setShowGrid(true);
setTimeout(() => {
setShowGrid(false);
}, 500);
};

return (
<div className={styles.palette}>
Expand All @@ -85,6 +91,7 @@ export default function AlbumArt() {
border: 0,
},
}}
onMediaLoaded={flashGrid}
onInteractionStart={() => setShowGrid(true)}
onInteractionEnd={() => setShowGrid(false)}
/>
Expand Down

0 comments on commit 891acac

Please sign in to comment.