mirror of
https://gitee.com/coder-xiaomo/algorithm-visualization
synced 2025-09-09 06:01:38 +08:00
完成选择排序算法;样式小调整
This commit is contained in:
@@ -26,11 +26,27 @@ body,
|
|||||||
|
|
||||||
#console-logs {
|
#console-logs {
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
margin-top: 8px;
|
||||||
padding: 0 15px;
|
padding: 0 15px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
width: 300px;
|
width: 300px;
|
||||||
background-color: #cccccc;
|
background-color: #cccccc;
|
||||||
overflow-y: overlay;
|
overflow-y: overlay;
|
||||||
border-radius: 12px;
|
border-radius: 10px;
|
||||||
user-select: none;
|
/* user-select: none; */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 滚动条样式 refer: https://www.changchenghao.cn/n/679637.html */
|
||||||
|
#console-logs::-webkit-scrollbar {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#console-logs::-webkit-scrollbar:vertical {
|
||||||
|
width: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#console-logs::-webkit-scrollbar-thumb {
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 2px solid white;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,8 @@
|
|||||||
function getSortClassList() {
|
function getSortClassList() {
|
||||||
return [
|
return [
|
||||||
QuickSort,
|
QuickSort,
|
||||||
BubbleSort
|
BubbleSort,
|
||||||
|
SelectionSort,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,9 +251,10 @@ class SelectionSort extends Sort {
|
|||||||
return array
|
return array
|
||||||
}
|
}
|
||||||
|
|
||||||
sortWithAnimation(array) {
|
sortWithAnimation(customAttr, array) {
|
||||||
let minIndex
|
let minIndex
|
||||||
for (let i = 0; i < array.length; i++) {
|
for (let i = 0; i < array.length; i++) {
|
||||||
|
// console.log(array)
|
||||||
minIndex = i
|
minIndex = i
|
||||||
for (let j = i + 1; j < array.length; j++) {
|
for (let j = i + 1; j < array.length; j++) {
|
||||||
animation.compareLinkedListItems(customAttr.id, minIndex, j)
|
animation.compareLinkedListItems(customAttr.id, minIndex, j)
|
||||||
|
@@ -73,7 +73,11 @@ function initialize() {
|
|||||||
ctrlBtn.innerHTML = sortClassInfo['name']
|
ctrlBtn.innerHTML = sortClassInfo['name']
|
||||||
ctrlBtn.onclick = function () {
|
ctrlBtn.onclick = function () {
|
||||||
controlDiv.style.display = 'none'
|
controlDiv.style.display = 'none'
|
||||||
d3.select("#console-div").style("display", "")
|
d3.select("#console-div")
|
||||||
|
.style("display", "")
|
||||||
|
d3.select("#console-current-algorithm")
|
||||||
|
.style("text-align", "center")
|
||||||
|
.html(sortClassInfo['name'])
|
||||||
sortClass.doSortWithAnimation(elementId)
|
sortClass.doSortWithAnimation(elementId)
|
||||||
}
|
}
|
||||||
DOMFragment.appendChild(ctrlBtn)
|
DOMFragment.appendChild(ctrlBtn)
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
<!-- <button id="btn_qucikSort">排序算法按钮</button> -->
|
<!-- <button id="btn_qucikSort">排序算法按钮</button> -->
|
||||||
</div>
|
</div>
|
||||||
<div id="console-div" style="display: none;">
|
<div id="console-div" style="display: none;">
|
||||||
|
<div id="console-current-algorithm"></div>
|
||||||
<div id="console-current-array"></div>
|
<div id="console-current-array"></div>
|
||||||
<div id="console-logs"></div>
|
<div id="console-logs"></div>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user