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

Xx-vue自定義指令實(shí)現(xiàn)點(diǎn)擊水波紋漣漪效果

 更新時(shí)間:2023年07月05日 10:34:21   作者:風(fēng)中凌亂的男子  
這篇文章主要為大家介紹了Xx-vue自定義指令實(shí)現(xiàn)點(diǎn)擊水波紋漣漪效果,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

目錄概覽:

|____
|____directive
| |____waves.css
| |____waves.js
|____main.js

waves.css

.waves-ripple {
    position: absolute;
    border-radius: 100%;
    background-image: radial-gradient(circle, rgba(255, 255, 255, .35) 100%, rgba(0, 0, 0, .15) 100%);
    background-clip: padding-box;
    pointer-events: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-transform: scale(0);
    -ms-transform: scale(0);
    transform: scale(0);
    opacity: 1;
}
.waves-ripple.z-active {
    opacity: 0;
    -webkit-transform: scale(2);
    -ms-transform: scale(2);
    transform: scale(2);
    -webkit-transition: opacity 1.2s ease-out, -webkit-transform 0.6s ease-out;
    transition: opacity 1.2s ease-out, -webkit-transform 0.6s ease-out;
    transition: opacity 1.2s ease-out, transform 0.6s ease-out;
    transition: opacity 1.2s ease-out, transform 0.6s ease-out, -webkit-transform 0.6s ease-out;
}

waves.js

import './waves.css';
const vueWaves = {};
vueWaves.install = (Vue, options = {}) => {
  Vue.directive('waves', {
    bind(el, binding) {
      el.addEventListener('click', e => {
        const customOpts = Object.assign(options, binding.value);
        const opts = Object.assign({
            ele: el, // 波紋作用元素
            type: 'hit', // hit點(diǎn)擊位置擴(kuò)散center中心點(diǎn)擴(kuò)展
            color: 'rgba(0, 0, 0, 0.15)' // 波紋顏色
          }, customOpts),
          target = opts.ele;
        if (target) {
          target.style.position = 'relative';
          target.style.overflow = 'hidden';
          const rect = target.getBoundingClientRect();
          let ripple = target.querySelector('.waves-ripple');
          if (!ripple) {
            ripple = document.createElement('span');
            ripple.className = 'waves-ripple';
            ripple.style.height = ripple.style.width = Math.max(rect.width, rect.height) + 'px';
            target.appendChild(ripple);
          } else {
            ripple.className = 'waves-ripple';
          }
          switch (opts.type) {
            case 'center':
              ripple.style.top = (rect.height / 2 - ripple.offsetHeight / 2) + 'px';
              ripple.style.left = (rect.width / 2 - ripple.offsetWidth / 2) + 'px';
              break;
            default:
              ripple.style.top = (e.pageY - rect.top - ripple.offsetHeight / 2 - document.body.scrollTop) + 'px';
              ripple.style.left = (e.pageX - rect.left - ripple.offsetWidth / 2 - document.body.scrollLeft) + 'px';
          }
          ripple.style.backgroundColor = opts.color;
          ripple.className = 'waves-ripple z-active';
          return false;
        }
      }, false);
    }
  })
};
export default vueWaves;

main.js

import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'
import vueWaves from './directive/waves'
Vue.use(vueWaves)
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>',
})

使用示例:

v-waves
<a class='header__crumbs--btn' @click.stop='goback' v-waves>返回</a>

以上就是Xx-vue自定義指令實(shí)現(xiàn)點(diǎn)擊水波紋漣漪效果的詳細(xì)內(nèi)容,更多關(guān)于Xx-vue點(diǎn)擊水波紋漣漪的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 解決vue移動(dòng)端適配問(wèn)題

    解決vue移動(dòng)端適配問(wèn)題

    這篇文章主要介紹了解決vue移動(dòng)端適配問(wèn)題,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-12-12
  • el-select去掉placeholder屬性的方法

    el-select去掉placeholder屬性的方法

    當(dāng)el-select的disabled屬性為true的時(shí)候不展示“請(qǐng)選擇”字樣,如何去掉el-select 元素的 placeholder 屬性呢,下面小編通過(guò)示例代碼給大家分享el-select如何去掉placeholder屬性,感興趣的朋友一起看看吧
    2023-12-12
  • Vue scrollBehavior 滾動(dòng)行為實(shí)現(xiàn)后退頁(yè)面顯示在上次瀏覽的位置

    Vue scrollBehavior 滾動(dòng)行為實(shí)現(xiàn)后退頁(yè)面顯示在上次瀏覽的位置

    這篇文章主要介紹了Vue scrollBehavior 滾動(dòng)行為實(shí)現(xiàn)后退頁(yè)面顯示在上次瀏覽的位置,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-05-05
  • el-date-picker默認(rèn)結(jié)束為當(dāng)前時(shí)分秒的操作方法

    el-date-picker默認(rèn)結(jié)束為當(dāng)前時(shí)分秒的操作方法

    在element?ui中的日期時(shí)間選擇組件中默認(rèn)是00:00,現(xiàn)在需求是點(diǎn)擊默認(rèn)結(jié)束時(shí)間為當(dāng)前時(shí)分秒,查了很多資料寫的都不準(zhǔn)確?,今天給大家分享el-date-picker默認(rèn)結(jié)束為當(dāng)前時(shí)分秒的操作方法,感興趣的朋友一起看看吧
    2024-01-01
  • 關(guān)于vue屬性使用和不使用冒號(hào)的區(qū)別說(shuō)明

    關(guān)于vue屬性使用和不使用冒號(hào)的區(qū)別說(shuō)明

    這篇文章主要介紹了關(guān)于vue屬性使用和不使用冒號(hào)的區(qū)別說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-10-10
  • vue實(shí)現(xiàn)拖拽進(jìn)度條

    vue實(shí)現(xiàn)拖拽進(jìn)度條

    這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)拖拽進(jìn)度條,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-03-03
  • 詳解Vue中使用Echarts的兩種方式

    詳解Vue中使用Echarts的兩種方式

    這篇文章主要介紹了Vue中使用Echarts的兩種方式,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-07-07
  • 詳解vuex中mutation/action的傳參方式

    詳解vuex中mutation/action的傳參方式

    這篇文章主要介紹了詳解vuex中mutation/action的傳參方式,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-08-08
  • vue實(shí)現(xiàn)加載頁(yè)面自動(dòng)觸發(fā)函數(shù)(及異步獲取數(shù)據(jù))

    vue實(shí)現(xiàn)加載頁(yè)面自動(dòng)觸發(fā)函數(shù)(及異步獲取數(shù)據(jù))

    這篇文章主要介紹了vue實(shí)現(xiàn)加載頁(yè)面自動(dòng)觸發(fā)函數(shù)(及異步獲取數(shù)據(jù)),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-07-07
  • vue3中setup語(yǔ)法糖下通用的分頁(yè)插件實(shí)例詳解

    vue3中setup語(yǔ)法糖下通用的分頁(yè)插件實(shí)例詳解

    這篇文章主要介紹了vue3中setup語(yǔ)法糖下通用的分頁(yè)插件,實(shí)例代碼介紹了自定義分頁(yè)插件:PagePlugin.vue,文中提到了vue3中setup語(yǔ)法糖下父子組件之間的通信,需要的朋友可以參考下
    2022-10-10

最新評(píng)論