Skip to content

Commit 4770a73

Browse files
committed
Transitions added Intervals Maintained
1 parent 25c915d commit 4770a73

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/App.svelte

+8-5
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@
3636
myBars
3737
);
3838
myBars = data;
39-
await new Promise((res, rej) => {
40-
setTimeout(() => {
41-
res();
42-
}, 500);
43-
});
39+
if (swap) {
40+
await new Promise((res, rej) => {
41+
setTimeout(() => {
42+
res();
43+
}, 500);
44+
});
45+
}
4446
}
4547
}
48+
alert("Array Sorted");
4649
};
4750
</script>
4851

src/components/Bar.svelte

+1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
width: 50px;
1010
background-color: rgb(8, 255, 160);
1111
margin-right: 5px;
12+
transition: all 0.5s;
1213
}
1314
</style>

src/functions/flash.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export async function flashBars(first, second, i, j, swap, array) {
99
if (swap) {
1010
first.classList.add("swapping");
1111
second.classList.add("swapping");
12-
setTimeout(() => {
12+
setTimeout(async() => {
1313
let temp = array[i];
1414
array[i] = array[j];
1515
array[j] = temp;
@@ -21,6 +21,6 @@ export async function flashBars(first, second, i, j, swap, array) {
2121
resolve(array);
2222
}
2323
}, 500);
24-
}, 1000);
24+
}, 800);
2525
});
2626
}

0 commit comments

Comments
 (0)