Skip to content

Commit

Permalink
Merge branch 'main' into custom-puzzles
Browse files Browse the repository at this point in the history
  • Loading branch information
skedwards88 authored Aug 19, 2024
2 parents 82236bd + 9c19cb4 commit 2438470
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "crossjig",
"version": "2.0.47",
"version": "2.0.48",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions src/logic/assemblePiece.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {getPieceDimension} from "./getPieceDimension";
// - letter: the letter
// - top: the vertical location in the piece
// - left: the horizontal location in the piece
// rowIndex todo
// colIndex todo
// rowIndex: The vertical location of the piece in the board, relative to how top/left for each letter in pieceData are defined.
// colIndex The horizontal location of the piece in the board, relative to how top/left for each letter in pieceData are defined.
export function assemblePiece({pieceData, rowIndex, colIndex}) {
const {numCols, numRows, minTop, minLeft} = getPieceDimension(pieceData);
const topAdjust = Math.abs(Math.min(0, minTop));
Expand Down Expand Up @@ -38,8 +38,8 @@ export function assemblePiece({pieceData, rowIndex, colIndex}) {
// - poolIndex (integer or undefined): The position of the piece in the pool. Undefined if the piece is on the board or being dragged.
// - boardTop (integer or undefined): The current vertical location of the top of the piece in the board. Undefined if the piece is in the pool or being dragged.
// - boardLeft (integer or undefined): The current horizontal location of the left of the piece in the board. Undefined if the piece is in the pool or being dragged
// - dragGroupTop (integer or undefined): todo. Undefined if the piece is not being dragged.
// - dragGroupLeft (integer or undefined): todo. Undefined if the piece is not being dragged.
// - dragGroupTop (integer or undefined): The vertical distance from the top of the piece to the top of the collection of pieces being dragged. Undefined if the piece is not being dragged.
// - dragGroupLeft (integer or undefined): The horizontal distance from the left of the piece to the left of the collection of pieces being dragged. Undefined if the piece is not being dragged.
export function updatePieceDatum(oldPieceData = {}, updates = {}) {
return {
...oldPieceData,
Expand Down
16 changes: 11 additions & 5 deletions src/logic/gameReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ function updateStateForDragStart({
for (const piece of currentGameState.pieces) {
if (isPartOfCurrentDrag(piece)) {
piecesBeingDragged.push(piece);
// todo figure out what is going on here

if (groupBoardTop !== undefined) {
// If the piece is on the board, set the groupBoardTop variable to be whichever is smaller:
// the top of the current piece, or the previously set groupBoardTop variable.
// This determines the top of the drag group.
// (Do the same for the left.)
// If the piece is not on the board, set the groupBoardTop to undefined,
// which will short circuit this block in the future.
if (piece.boardTop !== undefined) {
groupBoardTop = Math.min(groupBoardTop, piece.boardTop);
groupBoardLeft = Math.min(groupBoardLeft, piece.boardLeft);
Expand Down Expand Up @@ -86,11 +92,11 @@ function updateStateForDragStart({
if (rectangles.length === 0) {
return currentGameState;
}
const dragGroupTop = Math.min(...rectangles.map((rect) => rect.top));
const dragGroupLeft = Math.min(...rectangles.map((rect) => rect.left));
const dragGroupX = Math.min(...rectangles.map((rect) => rect.top));
const dragGroupY = Math.min(...rectangles.map((rect) => rect.left));
pointerOffset = {
x: pointerStartPosition.x - dragGroupLeft,
y: pointerStartPosition.y - dragGroupTop,
x: pointerStartPosition.x - dragGroupY,
y: pointerStartPosition.y - dragGroupX,
};
}

Expand Down

0 comments on commit 2438470

Please sign in to comment.