mirror of
https://gitee.com/coder-xiaomo/algorithm-visualization
synced 2025-01-10 11:48:18 +08:00
完成选择排序算法;样式小调整
This commit is contained in:
parent
e3f47b5bc3
commit
4e7a355e93
@ -26,11 +26,27 @@ body,
|
||||
|
||||
#console-logs {
|
||||
margin: 0 auto;
|
||||
margin-top: 8px;
|
||||
padding: 0 15px;
|
||||
height: 100px;
|
||||
width: 300px;
|
||||
background-color: #cccccc;
|
||||
overflow-y: overlay;
|
||||
border-radius: 12px;
|
||||
user-select: none;
|
||||
border-radius: 10px;
|
||||
/* 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() {
|
||||
return [
|
||||
QuickSort,
|
||||
BubbleSort
|
||||
BubbleSort,
|
||||
SelectionSort,
|
||||
]
|
||||
}
|
||||
|
||||
@ -250,9 +251,10 @@ class SelectionSort extends Sort {
|
||||
return array
|
||||
}
|
||||
|
||||
sortWithAnimation(array) {
|
||||
sortWithAnimation(customAttr, array) {
|
||||
let minIndex
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
// console.log(array)
|
||||
minIndex = i
|
||||
for (let j = i + 1; j < array.length; j++) {
|
||||
animation.compareLinkedListItems(customAttr.id, minIndex, j)
|
||||
|
@ -73,7 +73,11 @@ function initialize() {
|
||||
ctrlBtn.innerHTML = sortClassInfo['name']
|
||||
ctrlBtn.onclick = function () {
|
||||
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)
|
||||
}
|
||||
DOMFragment.appendChild(ctrlBtn)
|
||||
|
@ -22,6 +22,7 @@
|
||||
<!-- <button id="btn_qucikSort">排序算法按钮</button> -->
|
||||
</div>
|
||||
<div id="console-div" style="display: none;">
|
||||
<div id="console-current-algorithm"></div>
|
||||
<div id="console-current-array"></div>
|
||||
<div id="console-logs"></div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user