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

基于vue實現(xiàn)圓形菜單欄組件

 更新時間:2019年07月05日 16:30:45   作者:火辣辣  
這篇文章主要介紹了基于vue實現(xiàn)的圓形菜單欄組件,本文通過實例代碼,圖文詳解的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下

整個樣式都是基于css3 得transform而實現(xiàn)得。

每個扇形角度為360/12=30deg,當然,你不想做圓形也可以,公式就是     扇形角度=你想繪制得角度/扇形個數(shù)

當你計算好每個扇形得角度時,需要將li元素傾斜,傾斜角度=90-扇形面積,我的這個傾斜角度就是90-30=60deg,然后使用css3 得skew()

 

circle-panel-1

circle-panel-2

circle-panel-3

當每個扇形傾斜60deg之后,會在原來得位置上,要想每個扇形有規(guī)律得組合在一起,那么就要旋轉相應得角度,30deg,60deg,90deg…….這個以扇形得圓心角遞加。

這是基礎組件得完整代碼,父組件只需導入使用傳給子組件數(shù)據(jù)就可以了,當點擊每個扇形得事件也在父組件監(jiān)聽實現(xiàn)相應的邏輯。script部分我加了js代碼和ts代碼,沒有用過ts得小伙伴就忽略直接參考js代碼就可以了。并且我調用了手勢庫hammer.js,這個庫很全,大家感興趣得可以去查一下使用方法,這樣這個圓環(huán)是可以旋轉得。

<template>
 <div id="cn-wrapper" :style="{transform:'rotate('+rotatePanel+'deg)'}" class="cn-wrapper" >
  <ul>
   <li @click="clickPanel(item)" v-for="(item,index) in panel" :key="index">
    <a href="#">
     <img class="li-img" :src="item.img" alt />
     <div class="li-text">{{item.title}}</div>
    </a>
   </li>
  </ul>
 </div>
</template>
 
<script >
// import { Component, Prop, Vue,Emit } from 'vue-property-decorator';
 
// @Component
// export default class CirclePanel extends Vue {
//  private rotatePanel=0;
//  @Prop() panel!: any;
 
//  mounted(){
//   this.initPanel()
//  }
 
//   // 操作版
//  @Emit()
//  clickPanel(item:any){
//   return item;
//  }
//  initPanel(){
//   let panel=document.getElementById("cn-wrapper") as HTMLElement;
//   let panelMan = new Hammer.Manager(panel);
//   panelMan.add(new Hammer.Pan({
//     threshold: 0
//    }));
//   panelMan.on('panstart', (ev: any) => {
//    if (ev.center.x < panel.clientWidth/2) {//左邊
//     this.rotatePanel= this.rotatePanel - ev.angle
//    }else{
//     this.rotatePanel= this.rotatePanel + ev.angle
//     }
//   });
//  }
// }
 
export default {
   data () {
      return {
         rotatePanel: 0
      }
   },
   props: {
      panel: {
         type: Array,
         default: [    {img:'pics-gem/1.png',title:'一月石榴石'},
    {img:'pics-gem/2.png',title:'一月石榴石'},
    {img:'pics-gem/3.png',title:'一月石榴石'},
    {img:'pics-gem/4.png',title:'一月石榴石'},
    {img:'pics-gem/5.png',title:'一月石榴石'},
    {img:'pics-gem/6.png',title:'一月石榴石'},
    {img:'pics-gem/7.png',title:'一月石榴石'},
    {img:'pics-gem/8.png',title:'一月石榴石'},
    {img:'pics-gem/9.png',title:'一月石榴石'},
    {img:'pics-gem/10.png',title:'一月石榴石'},
    {img:'pics-gem/11.png',title:'一月石榴石'},
    {img:'pics-gem/12.png',title:'一月石榴石'},]
      },
   },
   activated(){
    this.initPanel()
   },
   methods: {
     // 操作版
     clickPanel(item){
      this.$emit('clickPanel',{item})
     },
     initPanel(){
      let panel=document.getElementById("cn-wrapper");
      let panelMan = new Hammer.Manager(panel);
      panelMan.add(new Hammer.Pan({
        threshold: 0
       }));
      panelMan.on('panstart', (ev) => {
       if (ev.center.x < panel.clientWidth/2) {//左邊
        this.rotatePanel= this.rotatePanel - ev.angle
       }else{
        this.rotatePanel= this.rotatePanel + ev.angle
        }
      });
     }
   }
}
</script>
 
<style scoped>
.cn-wrapper {
 font-size: 1em;
 width: 24em;
 height: 24em;
 overflow: hidden;
 position: fixed;
 z-index: 10;
 bottom: 84px;
 margin-left: -288px;
 left: 50%;
 border-radius: 50%;
 -webkit-transform: scale(0.1);
 -ms-transform: scale(0.1);
 -moz-transform: scale(0.1);
 transform: scale(1);
 /* pointer-events: none; */
 -webkit-transition: all 0.3s ease;
 -moz-transition: all 0.3s ease;
 transition: all 0.3s ease;
}
 
.cn-wrapper li {
 position: absolute;
 font-size: 1.5em;
 width: 10em;
 height: 10em;
 -webkit-transform-origin: 100% 100%;
 -moz-transform-origin: 100% 100%;
 -ms-transform-origin: 100% 100%;
 transform-origin: 100% 100%;
 overflow: hidden;
 left: 50%;
 /* top: 50%; */
 margin-top: -2em;
 /* border: solid 1px #f2cc81; */
 margin-left: -10em;
 -webkit-transition: border 0.3s ease;
 -moz-transition: border 0.3s ease;
 transition: border 0.3s ease;
}
 
.cn-wrapper li a {
 display: block;
 font-size: 1.18em;
 height: 14.5em;
 width: 14.5em;
 /* position: absolute; */
 position: fixed; /* fix the "displacement" bug in webkit browsers when using tab key */
 bottom: -7.25em;
 right: -7.25em;
 border-radius: 50%;
 text-decoration: none;
 color: #fff;
 padding-top: 1em;
 text-align: center;
 -webkit-transform: skew(-60deg) rotate(-70deg) scale(1);
 -ms-transform: skew(-60deg) rotate(-70deg) scale(1);
 -moz-transform: skew(-60deg) rotate(-70deg) scale(1);
 transform: skew(-60deg) rotate(-70deg) scale(1);
 -webkit-backface-visibility: hidden;
 -webkit-transition: opacity 0.3s, color 0.3s;
 -moz-transition: opacity 0.3s, color 0.3s;
 transition: opacity 0.3s, color 0.3s;
}
 
/* for a central angle x, the list items must be skewed by 90-x degrees
in our case x=40deg so skew angle is 50deg
items should be rotated by x, minus (sum of angles - 180)2s (for this demo) */
 
.cn-wrapper li:first-child {
 transform: rotate(-10deg) skew(60deg);
}
 
.cn-wrapper li:nth-child(2) {
 transform: rotate(20deg) skew(60deg);
}
 
.cn-wrapper li:nth-child(3) {
 transform: rotate(50deg) skew(60deg);
}
 
.cn-wrapper li:nth-child(4) {
 transform: rotate(80deg) skew(60deg);
}
 
.cn-wrapper li:nth-child(5) {
 transform: rotate(110deg) skew(60deg);
}
.cn-wrapper li:nth-child(6) {
 transform: rotate(140deg) skew(60deg);
}
.cn-wrapper li:nth-child(7) {
 transform: rotate(170deg) skew(60deg);
}
.cn-wrapper li:nth-child(8) {
 transform: rotate(200deg) skew(60deg);
}
.cn-wrapper li:nth-child(9) {
 transform: rotate(230deg) skew(60deg);
}
.cn-wrapper li:nth-child(10) {
 transform: rotate(260deg) skew(60deg);
}
.cn-wrapper li:nth-child(11) {
 transform: rotate(290deg) skew(60deg);
}
.cn-wrapper li:nth-child(12) {
 transform: rotate(320deg) skew(60deg);
}
 
.cn-wrapper li:nth-child(odd) a {
 background-color: #a11313;
 background-color: hsla(0, 88%, 63%, 1);
}
 
.cn-wrapper li:nth-child(even) a {
 background-color: #a61414;
 background-color: hsla(0, 88%, 65%, 1);
}
 
/* active style */
.cn-wrapper li.active a {
 /* background-color: #b31515;
 background-color: hsla(0, 88%, 70%, 1); */
 background-color: rgba(135, 137, 155, 0.52);
 border: solid 0px #f2cc81;
}
 
/* hover style */
.cn-wrapper li:not(.active) a:hover,
.cn-wrapper li:not(.active) a:active,
.cn-wrapper li:not(.active) a:focus {
 background-color: rgba(135, 137, 155, 0.52);
 border: solid 0px #f2cc81;
}
 
.li-img {
 width: 50px;
 margin-bottom: 44px;
 margin-left: -30px;
}
.li-text {
 color: #f2cc81;
 font-size: 20px;
 line-height: 1.4;
 width: 76px;
 margin: 0 calc(50% - 50px);
}
</style>

父組件調用:

 <div class="making-panel">
     <CirclePanel :title="title" :panel="panel"
           @clickTab="clickTabCircle"
           @clickPanel="clickPanel" ></CirclePanel>
  </div>

總結

以上所述是小編給大家介紹的基于vue實現(xiàn)圓形菜單欄組件,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!
如果你覺得本文對你有幫助,歡迎轉載,煩請注明出處,謝謝!

相關文章

  • vue中template的三種寫法示例

    vue中template的三種寫法示例

    這篇文章主要介紹了vue中template的三種寫法示例,幫助大家更好的理解和學習vue,感興趣的朋友可以了解下
    2020-10-10
  • vue 獲取及修改store.js里的公共變量實例

    vue 獲取及修改store.js里的公共變量實例

    今天小編就為大家分享一篇vue 獲取及修改store.js里的公共變量實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-11-11
  • Vue3 編譯流程-源碼解析

    Vue3 編譯流程-源碼解析

    今天將從 Vue 的入口文件開始,看看聲明了一個 Vue 的單文件之后是如何被 compile-core 編譯核心模塊編譯成渲染函數(shù)的。下面小編講解并附上代碼分析展現(xiàn)在文章里,感興趣的小伙伴不要錯過奧
    2021-09-09
  • 項目中一鍵添加husky實現(xiàn)詳解

    項目中一鍵添加husky實現(xiàn)詳解

    這篇文章主要為大家介紹了項目中一鍵添加husky實現(xiàn)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-09-09
  • vue實現(xiàn)商品列表的無限加載思路和步驟詳解

    vue實現(xiàn)商品列表的無限加載思路和步驟詳解

    這篇文章主要介紹了vue實現(xiàn)商品列表的無限加載思路和步驟詳解,基礎思路是觸底條件滿足之后 page++,拉取下一頁數(shù)據(jù),結合實例代碼給大家介紹的非常詳細,需要的朋友可以參考下,
    2024-06-06
  • 一文帶你上手vue3中的pinia

    一文帶你上手vue3中的pinia

    這篇文章主要以vue3+vite+ts舉例,為大家詳細介紹了vue3中pinia的安裝與使用,文中的示例代碼講解詳細,感興趣的小伙伴可以跟隨小編一起學習一下
    2023-09-09
  • vue中$emit傳遞多個參(arguments和$event)

    vue中$emit傳遞多個參(arguments和$event)

    本文主要介紹了vue中$emit傳遞多個參(arguments和$event),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2023-02-02
  • vue返回上一頁面時回到原先滾動的位置的方法

    vue返回上一頁面時回到原先滾動的位置的方法

    這篇文章主要介紹了vue返回上一頁面時回到原先滾動的位置的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-12-12
  • vue時間格式化實例代碼

    vue時間格式化實例代碼

    本篇文章主要介紹了vue時間格式化實例代碼,這里整理了詳細的代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • Vue實現(xiàn)學生管理功能

    Vue實現(xiàn)學生管理功能

    這篇文章主要為大家詳細介紹了Vue實現(xiàn)學生管理功能,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-06-06

最新評論