欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue實(shí)現(xiàn)移動(dòng)端可拖拽式icon圖標(biāo)

 更新時(shí)間:2022年03月02日 17:12:37   作者:進(jìn)了……  
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)移動(dòng)端可拖拽式icon圖標(biāo),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue實(shí)現(xiàn)移動(dòng)端可拖拽式icon圖標(biāo)的具體代碼,供大家參考,具體內(nèi)容如下

需求描述:在移動(dòng)端頁(yè)面懸浮一個(gè)可隨便拖拽的圖標(biāo),類似于蘋果手機(jī)的輔助觸控小圓點(diǎn),并且可隨意拖動(dòng)。

預(yù)覽:

組件代碼如下:

<template>
? ? <div class="ys-float-btn" :style="{'width':itemWidth+'px','height':itemHeight+'px','left':left+'px','top':top+'px'}"
? ? ? ? ?ref="div"
? ? ? ? ?@click ="onBtnClicked">
? ? ? ? <slot name="icon"></slot>
? ? ? ? <SvgIcon :iconClass="'changjianwentijieda'"
? ? ? ? ? ? ? ? ?:style="{'width':itemWidth+'px','height':itemHeight+'px'}"/>
? ? </div>
</template>
?
?
<script>
? ? export default {
? ? ? ? name: "DragIcon",
? ? ? ? props:{
? ? ? ? ? ? itemWidth:{
? ? ? ? ? ? ? ? type:Number,
? ? ? ? ? ? ? ? default:40
? ? ? ? ? ? },
? ? ? ? ? ? itemHeight:{
? ? ? ? ? ? ? ? type:Number,
? ? ? ? ? ? ? ? default:40
? ? ? ? ? ? },
? ? ? ? ? ? gapWidth:{
? ? ? ? ? ? ? ? type:Number,
? ? ? ? ? ? ? ? default:10
? ? ? ? ? ? },
?
? ? ? ? ? ? coefficientHeight:{
? ? ? ? ? ? ? ? type:Number,
? ? ? ? ? ? ? ? default:0.8
? ? ? ? ? ? }
? ? ? ? },
? ? ? ? created(){
? ? ? ? ? ? this.clientWidth = document.documentElement.clientWidth;
? ? ? ? ? ? this.clientHeight = document.documentElement.clientHeight;
? ? ? ? ? ? this.left = this.clientWidth - this.itemWidth - this.gapWidth;
? ? ? ? ? ? this.top = this.clientHeight*this.coefficientHeight;
? ? ? ? },
? ? ? ? mounted(){
? ? ? ? ? ? this.$nextTick(()=>{
? ? ? ? ? ? ? ? const div = this.$refs.div;
? ? ? ? ? ? ? ? div.addEventListener("touchstart",(e)=>{
? ? ? ? ? ? ? ? ? ? e.stopPropagation();
? ? ? ? ? ? ? ? ? ? div.style.transition = 'none';
? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? div.addEventListener("touchmove",(e)=>{
? ? ? ? ? ? ? ? ? ? ? ? e.stopPropagation();
? ? ? ? ? ? ? ? ? ? ? ? if (e.targetTouches.length === 1) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? let touch = event.targetTouches[0];
? ? ? ? ? ? ? ? ? ? ? ? ? ? this.left = touch.clientX - this.itemWidth/2;
? ? ? ? ? ? ? ? ? ? ? ? ? ? this.top = touch.clientY - this.itemHeight/2;
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? ? ? false
? ? ? ? ? ? ? ? );
? ? ? ? ? ? ? ? div.addEventListener("touchend",(e)=>{
? ? ? ? ? ? ? ? ? ? e.stopPropagation();
? ? ? ? ? ? ? ? ? ? div.style.transition = 'all 0.3s';
? ? ? ? ? ? ? ? ? ? if(this.left>this.clientWidth/2){
? ? ? ? ? ? ? ? ? ? ? ? this.left = this.clientWidth - this.itemWidth - this.gapWidth;
? ? ? ? ? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? ? ? ? ? this.left = this.gapWidth;
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? if(this.top<=36)
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? this.top=36+this.gapWidth
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? else{
? ? ? ? ? ? ? ? ? ? ? ? let bottom=this.clientHeight-50-this.itemHeight-this.gapWidth
? ? ? ? ? ? ? ? ? ? ? ? console.log(bottom,this.top)
? ? ? ? ? ? ? ? ? ? ? ? if(this.top>=bottom)
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? this.top=bottom
? ? ? ? ? ? ? ? ? ? ? ? }
?
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? });
? ? ? ? ? ? });
? ? ? ? },
?
? ? ? ? methods:{
? ? ? ? ? ? onBtnClicked(){
? ? ? ? ? ? ? ? this.$emit("onFloatBtnClicked");
? ? ? ? ? ? },
?
? ? ? ? },
? ? ? ? data(){
? ? ? ? ? ? return{
? ? ? ? ? ? ? ? timer:null,
? ? ? ? ? ? ? ? currentTop:0,
? ? ? ? ? ? ? ? clientWidth:0,
? ? ? ? ? ? ? ? clientHeight:0,
? ? ? ? ? ? ? ? left:0,
? ? ? ? ? ? ? ? top:0,
? ? ? ? ? ? }
? ? ? ? }
? ? }
</script>
?
<style lang="scss" scoped>
? ? .ys-float-btn{
? ? ? ? background:rgba(56,181,77,1);
? ? ? ? box-shadow:0 2px 10px 0 rgba(0,0,0,0.1);
? ? ? ? border-radius:50%;
? ? ? ? color: #666666;
? ? ? ? z-index: 20;
? ? ? ? transition: all 0.3s;
? ? ? ? display: flex;
? ? ? ? flex-direction: column;
? ? ? ? justify-content: center;
? ? ? ? align-items: center;
? ? ? ? position: fixed;
? ? ? ? bottom: 20vw;
?
? ? ? ? img{
? ? ? ? ? ? width: 50%;
? ? ? ? ? ? height: 50%;
? ? ? ? ? ? object-fit: contain;
? ? ? ? ? ? margin-bottom: 3px;
? ? ? ? }
? ? }
? ? .su_img{
? ? ? ? width: 40px;
? ? ? ? height: 40px;
? ? ? ? margin: 8px 0 0 0;
? ? }
?
</style>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • element tree樹形組件回顯數(shù)據(jù)問題解決

    element tree樹形組件回顯數(shù)據(jù)問題解決

    本文主要介紹了element tree樹形組件回顯數(shù)據(jù)問題解決,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2022-08-08
  • vue?為什么要封裝全局組件引入

    vue?為什么要封裝全局組件引入

    這篇文章主要介紹了vue為什么要封裝全局組件引入,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,感興趣的小伙伴可以參考一下
    2022-07-07
  • 這15個(gè)Vue指令,讓你的項(xiàng)目開發(fā)爽到爆

    這15個(gè)Vue指令,讓你的項(xiàng)目開發(fā)爽到爆

    這篇文章主要介紹了這15個(gè)Vue指令,讓你的項(xiàng)目開發(fā)爽到爆,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2019-10-10
  • Vue?項(xiàng)目性能優(yōu)化方案分享

    Vue?項(xiàng)目性能優(yōu)化方案分享

    本文是作者通過(guò)實(shí)際項(xiàng)目的優(yōu)化實(shí)踐進(jìn)行總結(jié)而來(lái),希望讀者讀完本文,有一定的啟發(fā)思考,從而對(duì)自己的項(xiàng)目進(jìn)行優(yōu)化起到幫助
    2022-08-08
  • 在vue中實(shí)現(xiàn)日歷功能的代碼示例

    在vue中實(shí)現(xiàn)日歷功能的代碼示例

    在許多Web應(yīng)用程序中,日歷是一個(gè)常見的組件,它通常用于顯示日期、安排會(huì)議、查看活動(dòng)等,在Vue中,我們可以使用第三方庫(kù)來(lái)輕松實(shí)現(xiàn)日歷功能,也可以手動(dòng)編寫代碼來(lái)實(shí)現(xiàn)日歷的展示和操作,本文將介紹如何使用vue-calendar和手動(dòng)編寫代碼來(lái)實(shí)現(xiàn)日歷功能
    2023-07-07
  • Vue使用axios出現(xiàn)options請(qǐng)求方法

    Vue使用axios出現(xiàn)options請(qǐng)求方法

    這篇文章主要介紹了Vue使用axios出現(xiàn)options請(qǐng)求,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-05-05
  • Vue實(shí)現(xiàn)Excel預(yù)覽功能使用場(chǎng)景示例詳解

    Vue實(shí)現(xiàn)Excel預(yù)覽功能使用場(chǎng)景示例詳解

    這篇文章主要為大家介紹了Vue實(shí)現(xiàn)Excel預(yù)覽功能使用場(chǎng)景示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-09-09
  • vue項(xiàng)目如何引入element?ui、iview和echarts

    vue項(xiàng)目如何引入element?ui、iview和echarts

    這篇文章主要介紹了vue項(xiàng)目如何引入element?ui、iview和echarts,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-09-09
  • vue等兩個(gè)接口都返回結(jié)果再執(zhí)行下一步的實(shí)例

    vue等兩個(gè)接口都返回結(jié)果再執(zhí)行下一步的實(shí)例

    這篇文章主要介紹了vue等兩個(gè)接口都返回結(jié)果再執(zhí)行下一步的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-09-09
  • Vue 2.0中生命周期與鉤子函數(shù)的一些理解

    Vue 2.0中生命周期與鉤子函數(shù)的一些理解

    這篇文章主要給大家介紹了關(guān)于Vue 2.0中生命周期與鉤子函數(shù)的相關(guān)資料,對(duì)大家學(xué)習(xí)或者使用vue2.0具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨小編一起來(lái)看看吧。
    2017-05-05

最新評(píng)論