diff --git a/src/components/ScrollPane/index.vue b/src/components/ScrollPane/index.vue
index ea13176d..1f633658 100644
--- a/src/components/ScrollPane/index.vue
+++ b/src/components/ScrollPane/index.vue
@@ -3,6 +3,10 @@
+
@@ -11,41 +15,83 @@ export default {
name: 'scrollPane',
data() {
return {
- left: 0
+ left: 0,
+ isOverflow: false,
+ container: undefined,
+ containerWidth: undefined,
+ wrapper: undefined,
+ wrapperWidth: undefined,
+ scrollbarContainer: undefined,
+ scrollbarContainerWidth: undefined,
+ scrollbar: undefined,
+ scrollbarWidth: undefined
}
},
+ mounted() {
+ this.container = this.$refs.scrollContainer
+ this.wrapper = this.$refs.scrollWrapper
+ this.scrollbarContainer = this.$refs.scrollbarContainer
+ this.scrollbar = this.$refs.scrollbar
+ this.calcSize()
+ window.addEventListener('resize', () => {
+ this.$forceUpdate()
+ this.calcSize()
+ }, false)
+ },
methods: {
+ calcPos() {
+ if (this.isOverflow) {
+ this.scrollbar.style.left = -(this.scrollbarContainerWidth - this.scrollbarWidth) * this.left / (this.wrapperWidth - this.containerWidth + 100) + 'px'
+ }
+ },
+ calcSize() {
+ // 计算滚动条的长度
+ this.containerWidth = parseFloat(this.container.offsetWidth, 10)
+ this.wrapperWidth = parseFloat(this.wrapper.offsetWidth, 10)
+ this.scrollbarContainerWidth = parseFloat(this.scrollbarContainer.offsetWidth, 10)
+ this.isOverflow = this.wrapperWidth + 100 > this.containerWidth
+ if (!this.isOverflow) return false
+ this.scrollbarWidth = this.scrollbarContainerWidth * this.containerWidth / (this.wrapperWidth + 100)
+ this.scrollbar.style.width = this.scrollbarWidth + 'px'
+ this.calcPos()
+ },
handleScroll(e) {
e.preventDefault()
- const $container = this.$refs.scrollContainer
- const $containerWidth = $container.offsetWidth
- const $wrapper = this.$refs.scrollWrapper
- const $wrapperWidth = $wrapper.offsetWidth
if (e.wheelDelta > 0) {
+ // 滚轮下滑
this.left = Math.min(0, this.left + e.wheelDelta)
} else {
- if ($containerWidth - 100 < $wrapperWidth) {
- if (this.left < -($wrapperWidth - $containerWidth + 100)) {
- this.left = this.left
- } else {
- this.left = Math.max(this.left + e.wheelDelta, $containerWidth - $wrapperWidth - 100)
- }
- } else {
- this.left = 0
+ // 滚轮上滑
+ // 可滑动区间[-(this.wrapperWidth-this.containerWidth+100),0]
+ if (this.left >= -(this.wrapperWidth - this.containerWidth + 100)) {
+ this.left = Math.max(this.left + e.wheelDelta, this.containerWidth - this.wrapperWidth - 100)
}
}
+ this.calcPos()
}
}
}
diff --git a/src/views/layout/components/TagsView.vue b/src/views/layout/components/TagsView.vue
index ec3acdf0..ce62f800 100644
--- a/src/views/layout/components/TagsView.vue
+++ b/src/views/layout/components/TagsView.vue
@@ -1,15 +1,17 @@
-
-
+
+
+
{{$t('route.'+tag.title)}}
+
-
+