0.2.6 • Published 3 years ago

vue2-slide-unlock v0.2.6

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

Disclaimer

The original project is here: https://github.com/chenbimo/vue-slide-unlock

This project has the same component, but is configured to work with Vue 2

vue-slide-unlock

CodeFactor npm npm bundle size Dependecy Status devDependencies Status

Vue.js 3.x slide to unlock component. Protect users from accidental clicks or protect your web app from bot attack.

You can check a DEMO HERE

Preview

Installation

You can install this component via npm:

npm install --save vue-slide-unlock

Usage

Import the component in your app and pass some settings:

<template>
    <slide-unlock
        ref="vueslideunlock"
        :auto-width="true"
        :circle="true"
        :disabled="false"
        :noanimate="false"
        :width="400"
        :height="60"
        text="slide to unlock"
        success-text="success"
        @completed="complete()"
    />
</template>

<script>
import SlideUnlock from "vue-slide-unlock"

export default {
    components: {
        SlideUnlock
    }
}
</script>

As you can see, the component accepts some props:

PropTypeDefaultDescription
autoWidthBooleantrueAuto width for component
circleBooleantrueAll parts of component will be with border-raduis and rounded handler
disabledBooleanfalseDisable interaction with component
noanimateBooleanfalseDisable css animations (but not css transitions)
widthNumber400Width of element (ignored if autoWidth is true)
heightNumber60Height of element
textStringslide to unlockText on element
successTextStringsuccessText on element when slide is completed

Also, you can customize some styles via CSS Variables:

VariableDefaultDescription
--su-size-text24pxFont size of text on element
--su-size-padding6pxPadding on element from progressbar
--su-color-bg#ebebebBackground color of element.
--su-color-progress-normal-bg#cacacaColor of progressbar
--su-color-progress-complete-bg#42b983Color of progressbar when slide is completed
--su-color-text-normal#4F4F4FColor of text on element
--su-color-text-complete#FEFEFEColor of text on element when slide is completed
--su-color-handler-bg#FFFFFFColor of handler

Event

this.$emit("completed")

Emitted when pass verify, the handler swiped to the right side.

Reset state

If you want to reset the state of a component, you need to assign a ref to the component

<template>
    <slide-unlock ref="vueslideunlock" />
</template>

And then you need to call the reset method

 methods: {
    reset() {
        this.$refs.vueslideunlock.reset()
    }
}
0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago