Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valid buttons attributes #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

<div class="js-spinner"> <!-- js-spinner is an important scoping class for the input controls. -->
<input type="number" step="4" max="10" min="0" data-stepper-debounce="400" class="js-stepper">
<button type="button" spinner-button="up" title="add 1">+</button>
<button type="button" spinner-button="down" title="subtract 1">-</button>
<button type="button" data-spinner-button="up" title="add 1" tabindex="-1">+</button>
<button type="button" data-spinner-button="down" title="subtract 1" tabindex="-1">-</button>
</div>

<script src="./../node_modules/jquery/dist/jquery.slim.min.js"></script>
<script src="./../dest/stepper.js"></script>
</body>
</html>
</html>
6 changes: 3 additions & 3 deletions dest/stepper.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dest/stepper.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dest/stepper.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Setting [options](https://github.com/gijsroge/stepper.js#options) is as simple a
<body>
<div class="js-spinner">
<input type="number" step="1" max="10" min="0" data-stepper-debounce="400" class="js-stepper">
<button type="button" spinner-button="up" title="add 1">+</button>
<button type="button" spinner-button="down" title="subtract 1">-</button>
<button type="button" data-spinner-button="up" title="add 1" tabindex="-1">+</button>
<button type="button" data-spinner-button="down" title="subtract 1" tabindex="-1">-</button>
</div>

<script src="jquery.js"></script>
Expand All @@ -39,4 +39,4 @@ debounce: 400, // Time in milliseconds to debounce the change event
- https://unpkg.com/stepper.js@1.0.3/dest/stepper.min.js

### Alternatives
- https://github.com/vsn4ik/jquery.spinner
- https://github.com/vsn4ik/jquery.spinner
6 changes: 3 additions & 3 deletions src/stepper.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@
const events = is_touch_device() ? 'touchstart' : 'mousedown';
var _this = this;

spinner.find('[spinner-button]')
spinner.find('[data-spinner-button]')
.on(events, function () {
const type = $(this).attr('spinner-button');
const type = $(this).attr('data-spinner-button');
if (type === 'up') {
$.fn.stepper.increase.call(_this);
} else {
$.fn.stepper.decrease.call(_this);
}
})
.on('mousedown', function () {
const type = $(this).attr('spinner-button');
const type = $(this).attr('data-spinner-button');
$(this).data('timer', setTimeout(() => {
timeout = setInterval(() => {
if (type === 'up') {
Expand Down