@phoenix-cg/v-tabs 0.1.32 → 0.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/v-tabs.common.js +26 -15
- package/dist/v-tabs.common.js.map +1 -1
- package/dist/v-tabs.umd.js +26 -15
- package/dist/v-tabs.umd.js.map +1 -1
- package/dist/v-tabs.umd.min.js +1 -1
- package/dist/v-tabs.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/VTabs.vue +23 -13
package/package.json
CHANGED
package/src/components/VTabs.vue
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
<div class="v-tabs-wrap">
|
|
3
3
|
<div ref="tabsEl" class="v-tabs" :class="[`__${direction}`]">
|
|
4
4
|
<div class="v-tabs_inner">
|
|
5
|
-
<
|
|
5
|
+
<component
|
|
6
|
+
:is="tabComponent"
|
|
6
7
|
v-for="tab in list"
|
|
7
8
|
:key="tab[trackBy]"
|
|
8
9
|
ref="tabs"
|
|
9
10
|
class="v-tabs_tab"
|
|
11
|
+
v-bind="tabProps(tab)"
|
|
10
12
|
:data-id="tab[trackBy]"
|
|
11
13
|
:class="{
|
|
12
14
|
__active: value && value[trackBy] === tab[trackBy],
|
|
@@ -24,10 +26,9 @@
|
|
|
24
26
|
{{ tab[label] || "" }}
|
|
25
27
|
</template>
|
|
26
28
|
</slot>
|
|
27
|
-
</
|
|
29
|
+
</component>
|
|
28
30
|
</div>
|
|
29
31
|
<div v-if="withSlider" :style="sliderStyle" class="v-tabs_slider" />
|
|
30
|
-
|
|
31
32
|
</div>
|
|
32
33
|
<component :is="mobileHintComponent" class="v-tabs-hint" :class="{ __visible: isHintVisible }" />
|
|
33
34
|
</div>
|
|
@@ -81,6 +82,14 @@ export default {
|
|
|
81
82
|
mobileHintHideDelay: {
|
|
82
83
|
type: Number,
|
|
83
84
|
default: 2000
|
|
85
|
+
},
|
|
86
|
+
tabComponent: {
|
|
87
|
+
type: String,
|
|
88
|
+
default: 'div'
|
|
89
|
+
},
|
|
90
|
+
tabProps: {
|
|
91
|
+
type: Function,
|
|
92
|
+
default: () => ({})
|
|
84
93
|
}
|
|
85
94
|
},
|
|
86
95
|
data () {
|
|
@@ -91,6 +100,11 @@ export default {
|
|
|
91
100
|
hintObserver: null
|
|
92
101
|
}
|
|
93
102
|
},
|
|
103
|
+
computed: {
|
|
104
|
+
hintShowCondition () {
|
|
105
|
+
return this.mobileHintComponent
|
|
106
|
+
}
|
|
107
|
+
},
|
|
94
108
|
watch: {
|
|
95
109
|
value () {
|
|
96
110
|
this.withSlider && this.calcSlider()
|
|
@@ -102,11 +116,6 @@ export default {
|
|
|
102
116
|
this.createHintObserver()
|
|
103
117
|
}
|
|
104
118
|
},
|
|
105
|
-
computed: {
|
|
106
|
-
hintShowCondition () {
|
|
107
|
-
return this.mobileHintComponent
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
119
|
mounted () {
|
|
111
120
|
if (this.selectFirst && this.list.length && !this.value) {
|
|
112
121
|
this.handleTabSelect(this.list[0])
|
|
@@ -128,18 +137,18 @@ export default {
|
|
|
128
137
|
},
|
|
129
138
|
createHintObserver () {
|
|
130
139
|
if (this.hintShowCondition) {
|
|
131
|
-
this.hintObserver = new IntersectionObserver(entries => {
|
|
140
|
+
this.hintObserver = new IntersectionObserver((entries, observer) => {
|
|
132
141
|
entries.forEach(entry => {
|
|
133
142
|
if (entry.isIntersecting) {
|
|
134
143
|
this.queueShowHint()
|
|
135
|
-
|
|
144
|
+
observer.disconnect()
|
|
136
145
|
this.hintObserver = null
|
|
137
146
|
}
|
|
138
147
|
})
|
|
139
148
|
}, {
|
|
140
149
|
threshold: 1.0
|
|
141
150
|
})
|
|
142
|
-
this.hintObserver.observe(this.$el)
|
|
151
|
+
// this.hintObserver.observe(this.$el)
|
|
143
152
|
}
|
|
144
153
|
},
|
|
145
154
|
queueShowHint () {
|
|
@@ -159,7 +168,8 @@ export default {
|
|
|
159
168
|
this.calcSlider()
|
|
160
169
|
})
|
|
161
170
|
this.$refs.tabs.forEach(tabEl => {
|
|
162
|
-
|
|
171
|
+
const el = tabEl.$el || tabEl
|
|
172
|
+
this.resizeObserver.observe(el)
|
|
163
173
|
})
|
|
164
174
|
}
|
|
165
175
|
},
|
|
@@ -232,5 +242,5 @@ export default {
|
|
|
232
242
|
}
|
|
233
243
|
.v-tabs-hint.__visible {
|
|
234
244
|
opacity: 1;
|
|
235
|
-
}
|
|
245
|
+
}
|
|
236
246
|
</style>
|