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

Debounce feature? #16

Open
lorro opened this issue Jan 2, 2019 · 2 comments
Open

Debounce feature? #16

lorro opened this issue Jan 2, 2019 · 2 comments

Comments

@lorro
Copy link

lorro commented Jan 2, 2019

Hi,

In the code I see a debounce value is supplied to the input control. But it doesn't seem to do much? The action is triggered immediately. My issue is that I show a notification on the screen everytime the changed quantity is actually saved, but when I do "holdMouseDown" to change the value quickly, I would get loads of notifications :)

If it would be possible to supply a debounce value so the linked method to the "input" event would only triggered after a certain amount of time, that would be handy I think.

When I tried to implement this with the _debounce feature of lodash I got some strange behavior.
Sometimes the spinner jumps by 2 instead of 1. My vue SFC has the following method.

    changeQuantity: _.debounce(function (id, qty) {
      return this.$store.dispatch('RECEIPT/CHANGE_PRODUCT_QUANTITY', { id, qty: parseInt(qty) })
        .then(data => {
          this.$toast.success(data.message)
        })
        .catch(data => this.$toast.error(data.message))
    }, 750)
@lorro
Copy link
Author

lorro commented Jan 3, 2019

Apparently it has nothing to do with the debounced function.

I just tried to add the following barebone component (without even any actions attached to the input event), and I get the same behavior when I click one of the buttons. It's really strange. Sometimes it jumps by two.

<NumberInputSpinner :min="0" :max="10" :integerOnly="true" />

In the demo I don't get this behavior.
I've made a small screencast to illustrate this.
video.zip

edit: I actually have the impression it's because of the mouseholddown. Perhaps I hold it for a ms too long what triggers the mouseholddown callback. A tiny delay on this could perhaps help?

@mapkbalaji
Copy link

This issue is not yet fixed, it seems..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants