代码提交
This commit is contained in:
@ -8,12 +8,9 @@
|
||||
<script setup>
|
||||
import { useScroll } from "@/hooks/useScroll";
|
||||
import { computed, onMounted, ref, toRefs, unref } from "vue";
|
||||
import UvIcon from "@/uni_modules/uv-icon/components/uv-icon/uv-icon.vue";
|
||||
import { useScreen } from "@/hooks/useScreen";
|
||||
import { useSystem } from "@/hooks/useSystem";
|
||||
import { CacheKey } from "@/utils/config";
|
||||
import { toTop } from "@/utils/images";
|
||||
|
||||
const {scrollTop, scrollToTop} = useScroll()
|
||||
const {getSystemInfo} = useSystem();
|
||||
|
||||
@ -28,11 +25,11 @@ const {getSystemInfo} = useSystem();
|
||||
const props = defineProps({
|
||||
top: {
|
||||
type: Number,
|
||||
default:200
|
||||
default:300
|
||||
},
|
||||
location: {
|
||||
type: Array,
|
||||
default: () => ([20, 200])
|
||||
default: () => ([20, 400])
|
||||
},
|
||||
size: {
|
||||
type: Number,
|
||||
@ -115,6 +112,7 @@ function handleTouchmove(e){
|
||||
|
||||
function handleTouchend(e){
|
||||
timeout&&clearTimeout(timeout)
|
||||
if(!isTouch.value) return handleClick()
|
||||
isTouch.value = false
|
||||
// 判断是否移动数据
|
||||
if(unref(touchLocation)[0]>0 || unref(touchLocation)[1]>0){
|
||||
@ -151,13 +149,13 @@ onMounted(async ()=>{
|
||||
class="return-top"
|
||||
:class="{touch:isTouch,click:animation}"
|
||||
:style="computedStyle"
|
||||
@touchstart="handleTouchstart"
|
||||
@touchstart.prevent="handleTouchstart"
|
||||
@touchmove.stop="handleTouchmove"
|
||||
@touchend="handleTouchend"
|
||||
@click="handleClick"
|
||||
>
|
||||
<slot>
|
||||
<image class="top-icon" :src="toTop" />
|
||||
<view class="top-icon" :style="{backgroundImage:`url(${toTop})`}" />
|
||||
</slot>
|
||||
</view>
|
||||
</template>
|
||||
@ -182,10 +180,13 @@ onMounted(async ()=>{
|
||||
}
|
||||
|
||||
.top-icon{
|
||||
user-select: none;
|
||||
width: 60%;
|
||||
height: 60%;
|
||||
border-radius: 50%;
|
||||
position: relative;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user