diff --git a/src/App.css b/src/App.css index 637574f5..47604575 100644 --- a/src/App.css +++ b/src/App.css @@ -197,4 +197,21 @@ body.webamp-loaded #webamp { .tinder-card { position: absolute; width: 100%; -} \ No newline at end of file +} + +#zoom button { + color: rgba(255, 2550, 2550, 0.9); +} +#zoom button:active, #zoom button:disabled { + color: grey; +} + +@media (hover: hover) { + #zoom { + opacity: 0.7; + transition: opacity 200ms ease-in-out; + } + #zoom:hover { + opacity: 1; + } +} diff --git a/src/App.js b/src/App.js index 36bc76cc..37279330 100644 --- a/src/App.js +++ b/src/App.js @@ -20,7 +20,7 @@ import { useDropzone } from "react-dropzone"; import ReviewPage from "./ReviewPage"; const getTableDimensions = (windowWidth, scale) => { - const columnCount = Math.floor(windowWidth / (SCREENSHOT_WIDTH * scale)); + const columnCount = Math.round(windowWidth / (SCREENSHOT_WIDTH * scale)); const columnWidth = windowWidth / columnCount; // TODO: Consider flooring this to get things aligned to the pixel const rowHeight = columnWidth * SKIN_RATIO; return { columnWidth, rowHeight, columnCount }; diff --git a/src/Header.js b/src/Header.js index 97b922e5..13f7a20b 100644 --- a/src/Header.js +++ b/src/Header.js @@ -60,7 +60,6 @@ function Header() { const showFeedbackForm = useActionCreator(Actions.showFeedbackForm); const requestRandomSkin = useActionCreator(Actions.requestedRandomSkin); const requestedAboutPage = useActionCreator(Actions.requestedAboutPage); - // const setScale = useActionCreator((scale) => ({ type: "SET_SCALE", scale })); const setInput = useFocusOnSlash(); return ( @@ -122,6 +121,7 @@ function Header() { onClick={() => { requestRandomSkin(); }} + title="Random Skin" style={{ paddingLeft: "0.2rem", paddingRight: "0.2rem", diff --git a/src/SkinTable.js b/src/SkinTable.js index 306882f1..3ba05074 100644 --- a/src/SkinTable.js +++ b/src/SkinTable.js @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useMemo } from "react"; import "./App.css"; import { connect } from "react-redux"; import * as Selectors from "./redux/selectors"; @@ -6,6 +6,7 @@ import * as Actions from "./redux/actionCreators"; import { FixedSizeGrid as Grid } from "react-window"; import Cell from "./Cell"; import { HEADING_HEIGHT } from "./constants"; +import Zoom from "./Zoom"; const SkinTable = ({ columnCount, @@ -30,31 +31,56 @@ const SkinTable = ({ return skin ? skin.hash : `unfectched-index-${requestToken}`; } const gridRef = React.useRef(); + const itemRef = React.useRef(); React.useLayoutEffect(() => { if (gridRef.current == null) { return; } gridRef.current.scrollTo({ scrollLeft: 0, scrollTop: 0 }); }, [skinCount]); + + React.useLayoutEffect(() => { + if (gridRef.current == null) { + return; + } + + const itemRow = Math.floor(itemRef.current / columnCount); + + gridRef.current.scrollTo({ scrollLeft: 0, scrollTop: rowHeight * itemRow }); + }, [rowHeight, columnCount]); + const showGrid = loadingSearchQuery || skinCount > 0 || searchQuery === ""; + + const onScroll = useMemo(() => { + const half = Math.round(columnCount / 2); + return (scrollData) => { + itemRef.current = + Math.round(scrollData.scrollTop / rowHeight) * columnCount + half; + }; + }, [columnCount, rowHeight]); + return (