123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <script setup lang="ts">
- import { ref, reactive, unref } from "vue";
- import SeamlessScroll from "@/components/ReSeamlessScroll";
- defineOptions({
- name: "SeamlessScroll"
- });
- const scroll = ref();
- const listData = ref([
- {
- title: "无缝滚动第一行无缝滚动第一行!!!!!!!!!!"
- },
- {
- title: "无缝滚动第二行无缝滚动第二行!!!!!!!!!!"
- },
- {
- title: "无缝滚动第三行无缝滚动第三行!!!!!!!!!!"
- },
- {
- title: "无缝滚动第四行无缝滚动第四行!!!!!!!!!!"
- },
- {
- title: "无缝滚动第五行无缝滚动第五行!!!!!!!!!!"
- },
- {
- title: "无缝滚动第六行无缝滚动第六行!!!!!!!!!!"
- },
- {
- title: "无缝滚动第七行无缝滚动第七行!!!!!!!!!!"
- },
- {
- title: "无缝滚动第八行无缝滚动第八行!!!!!!!!!!"
- },
- {
- title: "无缝滚动第九行无缝滚动第九行!!!!!!!!!!"
- }
- ]);
- const classOption = reactive({
- direction: "top"
- });
- function changeDirection(val) {
- (unref(scroll) as any).reset();
- unref(classOption).direction = val;
- }
- </script>
- <template>
- <el-space wrap>
- <el-card class="box-card" shadow="never">
- <template #header>
- <div class="card-header">
- <span class="font-medium">无缝滚动</span>
- <el-button
- class="button"
- link
- type="primary"
- @click="changeDirection('top')"
- >
- <span
- :style="{ color: classOption.direction === 'top' ? 'red' : '' }"
- >
- 向上滚动
- </span>
- </el-button>
- <el-button
- class="button"
- link
- type="primary"
- @click="changeDirection('bottom')"
- >
- <span
- :style="{
- color: classOption.direction === 'bottom' ? 'red' : ''
- }"
- >
- 向下滚动
- </span>
- </el-button>
- <el-button
- class="button"
- link
- type="primary"
- @click="changeDirection('left')"
- >
- <span
- :style="{ color: classOption.direction === 'left' ? 'red' : '' }"
- >
- 向左滚动
- </span>
- </el-button>
- <el-button
- class="button"
- link
- type="primary"
- @click="changeDirection('right')"
- >
- <span
- :style="{ color: classOption.direction === 'right' ? 'red' : '' }"
- >
- 向右滚动
- </span>
- </el-button>
- </div>
- <el-link
- class="mt-2"
- href="https://github.com/pure-admin/vue-pure-admin/blob/main/src/views/components/seamless-scroll.vue"
- target="_blank"
- >
- 代码位置 src/views/components/seamless-scroll.vue
- </el-link>
- </template>
- <SeamlessScroll
- ref="scroll"
- :data="listData"
- :class-option="classOption"
- class="warp"
- >
- <ul class="item">
- <li v-for="(item, index) in listData" :key="index">
- <span class="title" v-text="item.title" />
- </li>
- </ul>
- </SeamlessScroll>
- </el-card>
- </el-space>
- </template>
- <style lang="scss" scoped>
- .card-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- span {
- margin-right: 20px;
- }
- }
- .warp {
- width: 360px;
- height: 270px;
- margin: 0 auto;
- overflow: hidden;
- ul {
- padding: 0;
- margin: 0 auto;
- list-style: none;
- li,
- a {
- display: flex;
- justify-content: space-between;
- height: 30px;
- font-size: 15px;
- line-height: 30px;
- }
- }
- }
- </style>
|