2.0.1 • Published 2 months ago

@19h47/spinbutton v2.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 months ago

@19h47/spinbutton

A spinbutton is an input widget that restricts its value to a set or range of discrete values.

HTML

<div role="spinbutton" aria-valuemin="0" aria-valuemax="100" aria-valuenow="10">
	<button class="js-decrease" tabindex="-1" aria-label="decrease" type="button">-</button>

	<input type="number" />

	<button class="js-increase" tabindex="-1" aria-label="increase" type="button">+</button>
</div>

JavaScript

import SpinButton from '@19h47/spinbutton';

const $element = document.querySelector('[role="spinbutton"]');
const spinbutton = new SpinButton($element);

spinbutton.init();

Events

EventArgsDescription
SpinButton.changevalueReturn the current activate value
import SpinButton from '@19h47/spinbutton';

const $element = document.querySelector('[role="spinbutton"]');
const spinbutton = new SpinButton($element);

spinbutton.init();

spinbutton.on('SpinButton.change', value => {
	console.log(value);
});

Options

OptionType
textobjectObject containing single and plural text. Can be set as data attribute data-spinbutton-text

Keyboard Support

The spin buttons provide the following keyboard support described in the spin button design pattern.

KeyFunction
Down ArrowDecreases value 1 step.
Up ArrowIncreases the value 1 step.
Page DownDecreases the value 5 steps.
Page UpIncreases the value 5 steps.
HomeDecreases to mimimum value.
EndIncreases to maximum value.

Role, Property, State, and Tabindex Attributes

RoleAttributeElementUsage
spinbuttondivIdentifies the div element as a spinbutton.

References

Spinbutton Pattern

2.0.1

2 months ago

1.0.0

7 months ago

0.3.8

10 months ago

0.4.0

8 months ago

2.0.0

7 months ago

0.3.7

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.2

3 years ago

0.3.4

3 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.3

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.0

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago

0.0.0

4 years ago