ericjgagnon / wickedpicker

A simple jQuery timepicker
http://ericjgagnon.github.io/wickedpicker/
MIT License
93 stars 78 forks source link

Wicked time picker->> on clicking arrows, it increments/decrements by 2 #86

Open EngineerSE opened 4 years ago

macrado commented 3 years ago

I've experienced the same issue. I'm working on a laptop, and when I click by tapping the touchpad, the hour/minute increments by 2. When I click using the mouse buttons, I don't experience this.

I think the time between a mousedown event and a mouseup event when tapping the touchpad is the main issue. These are being misinterpreted as a "long press" and both the code for a click event and for a long press gets executed. I have two potential solutions.

First, in wickedpicker.js, line 463, within function HandleTimeAdjustments: $(this.up).add(this.down).off('mousedown click touchstart').on('mousedown click', { change to: $(this.up).add(this.down).off('mousedown click touchstart').on('click', { This is a (half-assed) way to disable the long-press that lets you scroll through the values quickly.

Alternatively, on a long press, add a delay before changing the value. In wickedpicker.js, line 470, replace the 'if' block with: if (event.type == 'mousedown') { var delay = 2; //the number of intervals to ignore before changing value timeOut = setInterval($.proxy(function (args) { if (delay == 0) { args.Wickedpicker.changeValue(operator, args.input, this); } else { delay--; } }, this, { 'Wickedpicker': passedData.Wickedpicker, 'input': passedData.input }), 200); } else { passedData.Wickedpicker.changeValue(operator, passedData.input, this); }

This adds a 400ms delay before registering a long press.

Disclaimer, I've barely tested this, use at your own risk, I'm not responsible for blowing up anyone's project, etc.