Skip to content

Commit

Permalink
修复组件:选项卡
Browse files Browse the repository at this point in the history
bny-tab:切换过快导致显示多个item的问题
  • Loading branch information
KingBes committed Dec 10, 2024
1 parent a997ba5 commit 2e83efb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/bunny.js

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions src/bny-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import tool from "./tool"

// 拓展-选项卡
(function () {

function beforeProcessNode(evt) {
const elem = evt.target
if (evt.target.classList.contains("bny-tab")) {
Expand All @@ -13,8 +13,12 @@ import tool from "./tool"
const index = tool.indexOf(this)
const parent = this.parentNode.parentNode
const body = htmx.find(parent, `.bny-tab-body>div:nth-child(${index + 1})`)
htmx.find(parent, ".bny-tab-title .this")?.classList.remove("this")
htmx.find(parent, ".bny-tab-body .this")?.classList.remove("this")
htmx.findAll(parent, ".bny-tab-title .this").forEach(function (v) {
v.classList.remove("this")
})
htmx.findAll(parent, ".bny-tab-body .this").forEach(function (vv) {
vv.classList.remove("this")
})
htmx.addClass(this, "this")
htmx.addClass(body, "this")
})
Expand Down

0 comments on commit 2e83efb

Please sign in to comment.