All Projects → javisperez → vuelongpress

javisperez / vuelongpress

Licence: MIT license
Confirmation button for sensitive action, which requires to be hold for an amount of seconds

Programming Languages

Vue
7211 projects
javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to vuelongpress

vue-loading-button
👇 Vue button with slideout loading indicator
Stars: ✭ 39 (-48%)
Mutual labels:  button
sleek button
A simple but yet customizable button.
Stars: ✭ 63 (-16%)
Mutual labels:  button
Hyena
鬣狗快速开发库(2018年6月停止维护)
Stars: ✭ 21 (-72%)
Mutual labels:  button
vue-burger-button
🍔 vue-burger-button is a functional component, which is faster than a regular component, and is pretty small (JS min+gzip is lower than 700b and CSS min+gzip is lower than 400b).
Stars: ✭ 41 (-45.33%)
Mutual labels:  button
bootstrap-directional-buttons
Directional / Arrow buttons for Bootstrap
Stars: ✭ 18 (-76%)
Mutual labels:  button
Night-Mode-Button
Easy to use night mode button with cool animation
Stars: ✭ 74 (-1.33%)
Mutual labels:  button
obvi
A Polymer 3+ webcomponent / button for doing speech recognition
Stars: ✭ 54 (-28%)
Mutual labels:  button
liquid button
Liquify your buttons, web demo at website
Stars: ✭ 18 (-76%)
Mutual labels:  button
FancyButtonProj
Juste a funcy button with progress bar
Stars: ✭ 27 (-64%)
Mutual labels:  button
react-native-animated-radio-button
Fully customizable animated radio button for React Native
Stars: ✭ 25 (-66.67%)
Mutual labels:  button
WechatPopupWindow
高仿微信聊天界面长按弹框样式
Stars: ✭ 71 (-5.33%)
Mutual labels:  longpress
aria-switch-control
ARIA Switch control component
Stars: ✭ 38 (-49.33%)
Mutual labels:  button
TabView
TabView for Android ——Slide indicator/button/tab; 滑动指示器/按钮/TAB控件
Stars: ✭ 22 (-70.67%)
Mutual labels:  button
smart-webcomponents-community
Material & Bootstrap Web Components built with Smart
Stars: ✭ 30 (-60%)
Mutual labels:  button
react-native-card-button
Fully customizable Card Button via Paraboly for React Native.
Stars: ✭ 16 (-78.67%)
Mutual labels:  button
captouch
👇 Add capacitive touch buttons to any FPGA!
Stars: ✭ 96 (+28%)
Mutual labels:  button
vscode-powertools
A swiss army knife with lots of tools, extensions and (scriptable) enhancements for Visual Studio Code.
Stars: ✭ 44 (-41.33%)
Mutual labels:  button
TextViewPlus
an android library for setting custom font in xml layout
Stars: ✭ 27 (-64%)
Mutual labels:  button
react-native-flat-button
Flat button component for react-native
Stars: ✭ 26 (-65.33%)
Mutual labels:  button
SSSwiftUISpinnerButton
SSSwiftUISpinnerButton is a collection of various spinning animations for buttons in SwiftUI.
Stars: ✭ 37 (-50.67%)
Mutual labels:  button

VueLongpress

A VueJS (2.x) button component that requires you to keep pressing to confirm a given action.

DEMO

Live demo on jsFiddle

What is this?

A component that will generate a button that requires you to keep pressing for a given time to execute a given action.

Why would i need that?

Think of a sensitive scenario, something like deleting a user's data, you might need to confirm for 5 seconds that you actually want to delete it, to prevent unintentional clicks

Install

Install from npm:

npm install vue-longpress --save

Example

import Longpress from 'vue-longpress';

var vm = new Vue({
	el: '#app',
	
	components: {Longpress},

    methods: {
        deleteUser() {
            // Delete the user login here
            console.log('user deleted');
        }
    },
	
	template: `<div>
	    <longpress duration="5" pressing-text="Keep pressing for {$rcounter} seconds to delete" action-text="Deleting, please wait...">Click and hold to delete this user</longpress>
	</div>`
});

Options / Props

This component support five (5) props:

  1. on-confirm: a callback function that will be called when the time has ellapsed (i.e. when the counter is 0)
  2. value: a value that is passed as an argument to the confirmation function
  3. duration: how long (in seconds) the user will need to keep pressing
  4. pressing-text: the text to display while the user needs to "hold" the click (e.g. Keep pressing to confirm)
  5. action-text: the text to display when the action is executing (e.g. Please wait...)

Also there's a reset method in case you need to reset your button status. To use it you'll need to add a ref to your button and call it from there.

e.g.:

In your template:

<longpress ref="deleteButton"></longpress>

In your method:

doDelete() {
    // delete logic here
    ...
    // and now reset the button if needed
    this.$refs.deleteButton.reset();
}

Labels templates

You can use these placeholders to display dynamic texts:

  1. {$counter} - how much time (in seconds) has ellapsed (i.e. from 0 to {$duration})
  2. {$rcounter} - how much time (in seconds) is remaining (i.e. from {$duration} to 0)
  3. {$duration} - how much should the user press the button in total (in seconds)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].