-
Notifications
You must be signed in to change notification settings - Fork 0
/
scroll-container.html
51 lines (44 loc) · 1016 Bytes
/
scroll-container.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<template>
<style>
:host {
overflow: hidden;
}
</style>
<div class="scroll-wrapper">
<div class="scroll-content">
<slot></slot>
</div>
</div>
</template>
<webox-scroll-container></webox-scroll-container>
<script>
customElements.define(
'webox-scroll-container',
class extends HTMLElement {
constructor() {
super()
this.attachShadow({ mode: 'open' })
this.shadowRoot.appendChild(template.content)
this.init()
}
init() {
const tabs = []
const children = this.shadowRoot.children
for (const elem of children) {
if (elem.getAttribute('part')) {
tabs.push(elem)
}
}
tabs.forEach((tab) => {
tab.addEventListener('click', (e) => {
tabs.forEach((tab) => {
tab.part = 'tab'
})
e.target.part = 'tab active'
})
console.log(tab.part)
})
}
}
)
</script>