Update script.js

This commit is contained in:
xixu-me committed 2024-11-29 08:16:38 +08:00
1 parent b3344fab92
commit 07167afb0d
1 file changed
+5 -1
+5 -1
View File
@@ -181,12 +181,14 @@ function startSCAN() {
if (initialDirection === "right") {
scanOrder = [
...sortedRequests.slice(headIndex),
199,
...sortedRequests.slice(0, headIndex).reverse(),
];
direction = 1;
} else {
scanOrder = [
...sortedRequests.slice(0, headIndex).reverse(),
0,
...sortedRequests.slice(headIndex),
];
direction = -1;
@@ -204,7 +206,9 @@ function startSCAN() {
}
const targetPosition = scanOrder[currentRequestIndex];
visitOrder.push(targetPosition);
if (targetPosition !== 0 && targetPosition !== 199) {
visitOrder.push(targetPosition);
}
const targetPixel = (targetPosition / 199) * trackWidth;
seekTime += Math.abs(targetPosition - currentPosition);