Commit 7ea854f
authored
Update turtles.js (#5044)
Summary
Optimizes window and turtle resizing behavior to feel smoother on high-end devices while preserving performance on lower-end hardware.
The change adapts dynamically based on device capability and avoids introducing overhead where it could cause lag.
Changes
1. Smooth Turtle Decoration Resize (js/turtle.js)
High-end devices (>4 cores):
Turtle decoration resize is animated using a short tween (~200ms) instead of snapping instantly.
Low-end devices:
Retains the original instant resize behavior to avoid performance overhead.
2. Optimized Window Resize Handling (js/turtles.js)
High-end devices:
Window resize events are throttled using requestAnimationFrame, allowing continuous, smooth canvas updates during resize.
Low-end devices:
Keeps the existing 150ms debounce logic so updates occur only after resizing ends.
3. Flicker Handling
An experimental bitmap scaling approach to reduce canvas flicker during resize was reverted.
The current implementation accepts native browser repaint behavior to preserve rendering correctness and simplicity.
Impact
Smoother, more responsive resizing on modern hardware.
No regression or added overhead on lower-end devices.
Improves perceived UI quality without changing existing behavior for beginners or constrained systems.1 parent d72d0dd commit 7ea854f
1 file changed
+24
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1248 | 1248 | | |
1249 | 1249 | | |
1250 | 1250 | | |
1251 | | - | |
| 1251 | + | |
1252 | 1252 | | |
| 1253 | + | |
| 1254 | + | |
1253 | 1255 | | |
1254 | | - | |
1255 | | - | |
1256 | | - | |
1257 | | - | |
1258 | | - | |
1259 | | - | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
1260 | 1277 | | |
1261 | 1278 | | |
1262 | 1279 | | |
| |||
0 commit comments