Install dependencies
npm install vue-seamless-scroll --save
After the installation is complete, reference the components
import vueSeamlessScroll from 'vue-seamless-scroll'
components: {
vueSeamlessScroll
}
parameter configuration
key | description | default | type |
---|---|---|---|
step |
The larger the value, the faster the scrolling speed. | 1 |
Number |
limitMoveNum |
Enable seamless scrolling of data | 5 |
Number |
hoverStop |
Whether to enable mouse hover control | true |
Boolean |
direction |
Direction 0 Down 1 Up 2 Left 3 Right | 1 |
Number |
openTouch |
Enable touch sliding on mobile terminal | true |
Boolean |
singleHeight |
The height at which single-step motion stops (default value 0 is seamless non-stop scrolling) direction => 0/1 | 0 |
Number |
singleWidth |
The width of the single-step movement stop (the default value 0 is seamless non-stop scrolling) direction => 2/3 | 0 |
Number |
waitTime |
Single step stop waiting time (default value 1000ms) | 1000 |
Number |
switchOffset |
The margin (px) between the left and right switch button and the left and right borders | 30 |
Number |
autoPlay |
Before version 1.1.17, it needs to be set to false when manually switching. | true |
Boolean |
switchSingleStep |
Manual single step switching step value (px) | 134 |
Number |
switchDelay |
Animation time of single-step switching (ms) | 400 |
Number |
switchDisabledClass |
The class name of the parent element of the switch button that cannot be clicked | disabled |
String |
isSingleRemUnit |
Whether singleHeight and singleWidth enable rem measurement | false |
Boolean |
navigation |
Whether to display controller buttons when scrolling in the left or right direction. When true, autoPlay automatically changes to false. | false |
Boolean |
data() {
return {
classOption: {
step: 0.5, // 数值越大速度滚动越快
limitMoveNum: 2, // 开始无缝滚动的数据量
hoverStop: true, // 是否开启鼠标悬停stop
direction: 1, // 0向下 1向上 2向左 3向右
openWatch: true, // 开启数据实时监控刷新dom
singleHeight: 0, // 单步运动停止的高度(默认值0是无缝不停止的滚动) direction => 0/1
singleWidth: 0, // 单步运动停止的宽度(默认值0是无缝不停止的滚动) direction => 2/3
waitTime: 1000 // 单步运动停止的时间(默认值1000ms)
}
}
}
example
<template>
<vue-seamless-scroll
class="overflow-hidden scroll-list"
:data="list"
:class-option="classOption"
>
<div class="d-flex">
<div
v-for="(item, index) in list"
:key="index"
class="main-top-item d-flex justify-content-between"
>
<div class="main-top-name d-flex justify-content-between flex-column">
<p class="iconfont-bg"><i class="iconfont" v-html="''" /></p>
<p class="main-top-label">{
{ item.monitoType }}</p>
</div>
<div class="main-top-cont d-flex justify-content-between flex-column p-2 ml-3">
<div class="main-top-box d-flex justify-content-between">
<span class="mr-2">本月累计</span>
<span class="text-orange">{
{ item.thisValue }}</span>
</div>
<div class="main-top-box d-flex justify-content-between">
<span class="mr-2">上月累计</span>
<span class="text-blue">{
{ item.lastValue }}</span>
</div>
</div>
</div>
</div>
</vue-seamless-scroll>
</template>
<script>
import vueSeamlessScroll from 'vue-seamless-scroll'
export default {
components: {
vueSeamlessScroll
},
data() {
return {
list: [],
classOption: {
step: 0.5, // 数值越大速度滚动越快
limitMoveNum: 5, // 开始无缝滚动的数据量
hoverStop: true, // 是否开启鼠标悬停stop
direction: 2, // 0向下 1向上 2向左 3向右
openWatch: true, // 开启数据实时监控刷新dom
singleHeight: 0, // 单步运动停止的高度(默认值0是无缝不停止的滚动) direction => 0/1
singleWidth: 0, // 单步运动停止的宽度(默认值0是无缝不停止的滚动) direction => 2/3
waitTime: 1000 // 单步运动停止的时间(默认值1000ms)
}
}
}
}
</script>
<style lang="scss" scoped>
.overflow-hidden{
overflow: hidden;
}
.scroll-list {
width: 2947px;
height: 108px;
}
</style>