1.0.3 • Published 5 years ago

vue-draggable-number v1.0.3

Weekly downloads
16
License
MIT
Repository
-
Last release
5 years ago

Vue Draggable Number

A simple number input component that users can edit by dragging the label around, inspired by Photoshop UX.

Written in Typescript.

Full demo: https://sunyatasattva.github.io/vue-draggable-number/

Demo of the component

Basic usage

<template>
  <div>
   <draggable-number-input v-model="someNumber" label="My number" />
  </div>
</template>

<script>
  export default {
    data() {
      return {
        someNumber: 1,
      };
    },
  };
</script>

This will create an unstyled HTML5 <input type="number"> tied to someNumber, the value of which the user can easily increase or decrease by dragging (respectively) up and down on the label.

The only two required properties are label and value (in the example case, handled through the v-model syntactic sugar).

Allowed props

PropertyDescriptionTypeDefaultOptions
dragDirectionThe axis in which the user has to drag to increase/decrease the number.String"Y""X""Y"
hideLabelWhether or not to hide the label.Booleanfalsetruefalse
labelThe label to show next to the input. It is also used to generate the name of the input and the class of the wrapper.String--
maxMaximum allowed value.NumberInfinity-
minMinimum allowed value.Number-Infinity-
stepThe amount by which the value is increased on mouse movement.Number1-
valueThe value of the input.Number--

The generated HTML looks like this:

<div class="vue-draggable-number-container ${generatedInputName}">
  <label for="${generatedInputName}"> {{ label }} </label>
  <input type="number" name="${generatedInputName}" />
</div>

Where ${generatedInputName} is draggable-number- plus the kebab-cased label.

These are useful to target the component for styling.

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago