Git Product home page Git Product logo

surmon-china / vue-touch-ripple Goto Github PK

View Code? Open in Web Editor NEW
480.0 14.0 42.0 575 KB

A ink-ripple effect component for @vuejs

Home Page: https://github.surmon.me/vue-touch-ripple

License: MIT License

JavaScript 2.67% Vue 20.08% TypeScript 70.81% HTML 2.00% Shell 1.51% SCSS 2.93%
vue vue-touch-ripple vue-component ripple vue-resource vue-plugin touch-ripple material-design ink-ripple vue-ink-ripple

vue-touch-ripple's Introduction

vue-touch-ripple

vue   GitHub stars   npm   Test Codecov   license

Make any element easily have a Material Design-style click "ink ripple" effect.


Usage

Install

yarn add vue-touch-ripple
npm install vue-touch-ripple --save

Local component

<template>
  <touch-ripple
    color="#fff"
    :opacity="0.4"
    transition="ease-out"
    :duration="400"
    :keep-last-ripple="true"
    @touch="log('touch', $event)"
    @click="log('click', $event)"
    @start="log('ripple-start', $event)"
    @end="log('ripple-end', $event)"
  >
    <!-- your content element -->
    <div class="content">Target content</div>
  </touch-ripple>
</template>

<script>
  import { defineComponent } from 'vue'
  import { TouchRipple } from 'vue-touch-ripple'
  import 'vue-touch-ripple/style.css'

  export default defineComponent({
    components: {
      TouchRipple
    },
    methods: {
      log: console.log
    }
  })
</script>

Global component

import { createApp } from 'vue'
import VueTouchRipple from 'vue-touch-ripple'
import 'vue-touch-ripple/style.css'

const app = createApp()

app.use(VueTouchRipple, {
  // optional default global options
  color: 'red',
  opacity: 0.5,
  duration: 280,
  transition: 'ease',
  keepLastRipple: false
})

Component Props

prop description type default
color Specify the background color of the ripple layer, supporting any legal color value such as RGBA. String #fff
opacity Transparency of ripple layers, supporting numbers from 0 ~ 1. Number 0.3
duration Duration of single ripple motion, time in milliseconds. Number 380
transition Ripple motion animation curve with Bezier curve value support. String ease-out
keepLastRipple whether to keep the last ripple (if true, the last ripple will always be present until the mouse button is released) Boolean true

Component Events

event description params
touch When the component is pressed by the left mouse button. (event: MouseEvent)
click When the component is lifted by the left mouse button. (event: MouseEvent)
start When the animated animation of each ripple starts. (id: number)
end When the animated motion of each ripple ends. (id: number)

BTW: if you expect to bind more flexible events on the component, in Vue3 you can just bind the events directly, instead of using the @xxx.native modifier in Vue2.

Changelog

Detailed changes for each release are documented in the release notes.

License

Licensed under the MIT License.

vue-touch-ripple's People

Contributors

dependabot[bot] avatar fry95116 avatar surmon-china avatar throrin19 avatar timrchen avatar torvaldssg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-touch-ripple's Issues

Touching and dragging the event outside initial target causes a build up of elements

中文用户注意:

  1. 尽量用英文描述你的 issue
  2. 不要把内容堆彻在标题上,逻辑清晰地写在内容区
  3. 贴代码要提前格式化好,有颜色高亮那种,贴文本,不要贴图片
  4. 提问题前,必须仔细阅读 REMADE.md + 在已关闭的问题中寻找与自身相关的问题,90% 的可能它已经被解决
  5. 如果无法做到提一个合格、优秀的问题,则问题会被 close + block

BUG REPORT TEMPLATE

Vue.js version and component version

Reproduction Link

  • A minimal JSBin, JSFiddle, Codepen, or a GitHub repository that can reproduce the bug.
  • You could start with this template: https://jsfiddle.net/39epgLj0/

Steps to reproduce

What is Expected?

What is actually happening?

有没有办法通过引入js的方式直接使用呢?

项目这边其他人都是非node技术栈,很难说服用import、webpack、require并且还要编译成es5的js,所以能否提供像Vue.js一样直接在页面中的script标签src="vue-touch-ripple.min.js"这样的方式来使用呢?感谢开发者~

[important] Touch Ripple don't works with the latest vue-loader

With the latest vue Loader version 12.0.x, the touch-ripple don't works correctly :

peek 17-05-2017 09-57

With the previous version, it works fine. After research I find the problem. In the 12.0.0 it was a "small breaking change" :

Upgrading vue-style-loader to 3.0 introduces a small breaking change: the CSS contained in a *.vue component will now be lazy-injected, when the component is rendered for the first time. (Previously the style is injected as soon as the component is imported.)

And after other researchs, I find this post to show how to fix that : https://forum.vuejs.org/t/overriding-child-component-classes-with-vue-loader-12-0-0/10369

SCRIPT1002: Syntax Error

I'm getting some error in IE10 related to SCRIPT1002: Syntax Error on app.js (1633,1):


eval(" /**\n *\n * Vue-touch-ripple\n * Adapted from rippleJS (https://github.com/samthor/rippleJS)\n * removed jQuery\n *\n */\n\nconst directive = __webpack_require__(146)\nconst component = __webpack_require__(142)\n\nconst vueTouchRipple = {\n  touchRipple: component,\n  install: function(Vue) {\n\n    // component\n    Vue.component('touch-ripple', component)\n\n    // directive\n    Vue.directive('touch-ripple', directive)\n  }\n}\n\nmodule.exports = vueTouchRipple\n\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTQ3LmpzIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8vLy4vfi92dWUtdG91Y2gtcmlwcGxlL2luZGV4LmpzPzRmZmYiXSwic291cmNlc0NvbnRlbnQiOlsiIC8qKlxuICpcbiAqIFZ1ZS10b3VjaC1yaXBwbGVcbiAqIEFkYXB0ZWQgZnJvbSByaXBwbGVKUyAoaHR0cHM6Ly9naXRodWIuY29tL3NhbXRob3IvcmlwcGxlSlMpXG4gKiByZW1vdmVkIGpRdWVyeVxuICpcbiAqL1xuXG5jb25zdCBkaXJlY3RpdmUgPSByZXF1aXJlKCcuL2RpcmVjdGl2ZS5qcycpXG5jb25zdCBjb21wb25lbnQgPSByZXF1aXJlKCcuL2NvbXBvbmVudC52dWUnKVxuXG5jb25zdCB2dWVUb3VjaFJpcHBsZSA9IHtcbiAgdG91Y2hSaXBwbGU6IGNvbXBvbmVudCxcbiAgaW5zdGFsbDogZnVuY3Rpb24oVnVlKSB7XG5cbiAgICAvLyBjb21wb25lbnRcbiAgICBWdWUuY29tcG9uZW50KCd0b3VjaC1yaXBwbGUnLCBjb21wb25lbnQpXG5cbiAgICAvLyBkaXJlY3RpdmVcbiAgICBWdWUuZGlyZWN0aXZlKCd0b3VjaC1yaXBwbGUnLCBkaXJlY3RpdmUpXG4gIH1cbn1cblxubW9kdWxlLmV4cG9ydHMgPSB2dWVUb3VjaFJpcHBsZVxuXG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gLi9+L3Z1ZS10b3VjaC1yaXBwbGUvaW5kZXguanNcbi8vIG1vZHVsZSBpZCA9IDE0N1xuLy8gbW9kdWxlIGNodW5rcyA9IDAiXSwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTsiLCJzb3VyY2VSb290IjoiIn0=");

There is a way to fix it?

ios 延迟

体验式感觉不是 touch 事件 像是 click事件。
延迟半拍
尤其是 如果这个 按钮是 a 标签需要跳转的时候。动画根本就放不完就跳转了。

配合路由使用

这个是否可以配合路由使用,在点击之后,页面跳转之前实现这个效果?

Vue warn when using "v-touch-ripple" ?

Property or method "ripple" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.

滑动问题

当作用在 多条列表上的时候
滚动的时候会触发效果
应该做个判断。

  • Vue 3 Support

    As Vue 3 has RC It will be a good idea to add support for Vue 3.

    Currently, if we use this package with Vue 3 we are getting error.

    image

    vue-cli npm run build 错误

    ERROR in static/js/vendor.c97fad4c6740d5d63c37.js from UglifyJs
    SyntaxError: Unexpected token: name (touchs) [./~/.npminstall/vue-touch-ripple/2.3.0/vue-touch-ripple/touchripple.js:97,0]

    vue 2.0

    这把子标签里的事件都覆盖了吗 事件都不起作用了

    中文用户注意:

    1. 尽量用英文描述你的 issue
    2. 不要把内容堆彻在标题上,逻辑清晰地写在内容区
    3. 贴代码要提前格式化好,有颜色高亮那种,贴文本,不要贴图片
    4. 提问题前,必须仔细阅读 REMADE.md + 在已关闭的问题中寻找与自身相关的问题,90% 的可能它已经被解决
    5. 如果无法做到提一个合格、优秀的问题,则问题会被 close + block

    BUG REPORT TEMPLATE

    Vue.js version and component version

    Reproduction Link

    • A minimal JSBin, JSFiddle, Codepen, or a GitHub repository that can reproduce the bug.
    • You could start with this template: https://jsfiddle.net/39epgLj0/

    Steps to reproduce

    What is Expected?

    What is actually happening?

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. 📊📈🎉

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google ❤️ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.