$P@D$3RV£R commited on
Commit ·
786ea11
1
Parent(s): f5ea0f9
Improve rendering logic to ensure new tiles always appear after matches
Browse files
game.js
CHANGED
|
@@ -248,7 +248,25 @@ class Match3Game {
|
|
| 248 |
const expectedClass = `cell gem-${gemType}`;
|
| 249 |
const expectedEmoji = this.getGemEmoji(gemType);
|
| 250 |
|
| 251 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
const currentGemClass = Array.from(cell.classList).find(c => c.startsWith('gem-'));
|
| 253 |
const needsUpdate = needsFullRender ||
|
| 254 |
currentGemClass !== `gem-${gemType}` ||
|
|
@@ -260,22 +278,6 @@ class Match3Game {
|
|
| 260 |
const isMatchEnlarge = cell.classList.contains('match-enlarge');
|
| 261 |
const hasActiveAnimation = isMatched || isMatchEnlarge;
|
| 262 |
|
| 263 |
-
// Skip if cell is marked as empty (-1)
|
| 264 |
-
if (gemType === -1) {
|
| 265 |
-
// Hide empty cells but don't manipulate inline styles repeatedly
|
| 266 |
-
if (!cell.classList.contains('empty-cell')) {
|
| 267 |
-
cell.classList.add('empty-cell');
|
| 268 |
-
cell.style.display = 'none';
|
| 269 |
-
}
|
| 270 |
-
continue;
|
| 271 |
-
}
|
| 272 |
-
|
| 273 |
-
// Remove empty-cell class if present
|
| 274 |
-
if (cell.classList.contains('empty-cell')) {
|
| 275 |
-
cell.classList.remove('empty-cell');
|
| 276 |
-
cell.style.display = '';
|
| 277 |
-
}
|
| 278 |
-
|
| 279 |
// Only update if not animating
|
| 280 |
if (!hasActiveAnimation) {
|
| 281 |
// Always ensure cell is visible for non-empty cells
|
|
@@ -292,19 +294,6 @@ class Match3Game {
|
|
| 292 |
cell.style.transition = '';
|
| 293 |
}
|
| 294 |
}
|
| 295 |
-
} else {
|
| 296 |
-
// Even if no update needed, ensure visibility is correct
|
| 297 |
-
if (gemType === -1) {
|
| 298 |
-
if (!cell.classList.contains('empty-cell')) {
|
| 299 |
-
cell.classList.add('empty-cell');
|
| 300 |
-
cell.style.display = 'none';
|
| 301 |
-
}
|
| 302 |
-
} else {
|
| 303 |
-
if (cell.classList.contains('empty-cell')) {
|
| 304 |
-
cell.classList.remove('empty-cell');
|
| 305 |
-
cell.style.display = '';
|
| 306 |
-
}
|
| 307 |
-
}
|
| 308 |
}
|
| 309 |
}
|
| 310 |
}
|
|
|
|
| 248 |
const expectedClass = `cell gem-${gemType}`;
|
| 249 |
const expectedEmoji = this.getGemEmoji(gemType);
|
| 250 |
|
| 251 |
+
// Handle empty cells first
|
| 252 |
+
if (gemType === -1) {
|
| 253 |
+
// Hide empty cells
|
| 254 |
+
if (!cell.classList.contains('empty-cell')) {
|
| 255 |
+
cell.classList.add('empty-cell');
|
| 256 |
+
cell.style.display = 'none';
|
| 257 |
+
}
|
| 258 |
+
continue;
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
// Remove empty-cell class and ensure visibility for non-empty cells
|
| 262 |
+
if (cell.classList.contains('empty-cell')) {
|
| 263 |
+
cell.classList.remove('empty-cell');
|
| 264 |
+
cell.style.display = '';
|
| 265 |
+
cell.style.opacity = '';
|
| 266 |
+
cell.style.visibility = '';
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
// Check if cell needs update
|
| 270 |
const currentGemClass = Array.from(cell.classList).find(c => c.startsWith('gem-'));
|
| 271 |
const needsUpdate = needsFullRender ||
|
| 272 |
currentGemClass !== `gem-${gemType}` ||
|
|
|
|
| 278 |
const isMatchEnlarge = cell.classList.contains('match-enlarge');
|
| 279 |
const hasActiveAnimation = isMatched || isMatchEnlarge;
|
| 280 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
// Only update if not animating
|
| 282 |
if (!hasActiveAnimation) {
|
| 283 |
// Always ensure cell is visible for non-empty cells
|
|
|
|
| 294 |
cell.style.transition = '';
|
| 295 |
}
|
| 296 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
}
|
| 298 |
}
|
| 299 |
}
|