-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<template> | ||
<el-card class="box-card"> | ||
<template #header> | ||
<div class="card-header"> | ||
<span>无缝滚动示例</span> | ||
<el-button class="button" type="text" @click="changeDirection('top')"> | ||
<span :style="{ color: classOption.direction === 'top' ? 'red' : '' }">向上滚动</span> | ||
</el-button> | ||
<el-button class="button" type="text" @click="changeDirection('bottom')"> | ||
<span | ||
:style="{ | ||
color: classOption.direction === 'bottom' ? 'red' : '', | ||
}" | ||
>向下滚动</span | ||
> | ||
</el-button> | ||
<el-button class="button" type="text" @click="changeDirection('left')"> | ||
<span :style="{ color: classOption.direction === 'left' ? 'red' : '' }">向左滚动</span> | ||
</el-button> | ||
<el-button class="button" type="text" @click="changeDirection('right')"> | ||
<span :style="{ color: classOption.direction === 'right' ? 'red' : '' }">向右滚动</span> | ||
</el-button> | ||
</div> | ||
</template> | ||
<SeamlessScroll ref="scroll" :data="listData" :class-option="classOption" class="warp"> | ||
<ul class="item"> | ||
<li v-for="(item, index) in listData" :key="index"> | ||
{{ item.title }} | ||
</li> | ||
</ul> | ||
</SeamlessScroll> | ||
</el-card> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref, reactive, unref } from 'vue'; | ||
import { templateRef } from '@vueuse/core'; | ||
import SeamlessScroll from '@/components/SeamlessScroll/index.vue'; | ||
// eslint-disable-next-line no-undef | ||
const scroll = templateRef<HTMLElement | null>('scroll', null); | ||
let listData = ref([ | ||
{ | ||
title: '无缝滚动第一行无缝滚动第一行!!!!!!!!!!', | ||
}, | ||
{ | ||
title: '无缝滚动第二行无缝滚动第二行!!!!!!!!!!', | ||
}, | ||
{ | ||
title: '无缝滚动第三行无缝滚动第三行!!!!!!!!!!', | ||
}, | ||
{ | ||
title: '无缝滚动第四行无缝滚动第四行!!!!!!!!!!', | ||
}, | ||
{ | ||
title: '无缝滚动第五行无缝滚动第五行!!!!!!!!!!', | ||
}, | ||
{ | ||
title: '无缝滚动第六行无缝滚动第六行!!!!!!!!!!', | ||
}, | ||
{ | ||
title: '无缝滚动第七行无缝滚动第七行!!!!!!!!!!', | ||
}, | ||
{ | ||
title: '无缝滚动第八行无缝滚动第八行!!!!!!!!!!', | ||
}, | ||
{ | ||
title: '无缝滚动第九行无缝滚动第九行!!!!!!!!!!', | ||
}, | ||
]); | ||
let classOption = reactive({ | ||
direction: 'top', | ||
}); | ||
function changeDirection(val: string) { | ||
// @ts-ignore | ||
unref(scroll).reset(); | ||
unref(classOption).direction = val; | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.card-header { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
span { | ||
margin-right: 20px; | ||
} | ||
} | ||
.warp { | ||
height: 200px; | ||
width: 400px; | ||
margin: 0 auto; | ||
overflow: hidden; | ||
ul { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters