#Crossword Game Web, Vertical typing next cell problem

3 messages · Page 1 of 1 (latest)

fringe cosmos
#
findNextCell() {
        if (!this.selectedCell) return null;
    
        const table = this.selectedCell.closest('table');
        const currentRow = this.selectedCell.parentElement;
        const rowIndex = currentRow.rowIndex;
        const cellIndex = this.selectedCell.cellIndex;
    
        if (this.currentDirection === CONFIG.DIRECTIONS.ACROSS) {
            // find next cell in horizontal direction
            const nextCell = currentRow.cells[cellIndex + 1];
            if (nextCell && nextCell.classList.contains('box2')) {
                return nextCell;
            }
        } else if (this.currentDirection === CONFIG.DIRECTIONS.DOWN) {
            // find next cell in vertical direction
            if (rowIndex + 1 < table.rows.length) {
                const nextRow = table.rows[rowIndex + 1];
                if (nextRow) {
                    const nextCell = nextRow.cells[cellIndex];
                    if (nextCell && nextCell.classList.contains('box2')) {
                        return nextCell;
                    }
                }
            }
        }
    
        // if not found, return null
        return null;
    }
timid flame
#

I have question.
Is the this.currentDirection updated when you are trying?

timid flame