Skip to content

Commit

Permalink
frontend bugfix: nudge can cause duplicate actions
Browse files Browse the repository at this point in the history
  • Loading branch information
justparking authored May 15, 2023
2 parents f5d4142 + f6ccadd commit 1215270
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion nodel-webui-js/src/nodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,16 @@ var setEvents = function(){
* 2) touch event flow
* - touchstart -> touchend
* - touchmove
*
* 3) Panel's webview
* - click touchend
* - "mousedown touchstart" : When quickly clicking, can be called 2x, which causes problem.
* - click touchend
*
* 4) Desktop's chrome
* - mousedown touchstart
* - click touchend
*
*/

function callNudgeAction(jqObj, weight) {
Expand All @@ -1079,6 +1089,13 @@ var setEvents = function(){
}

$('body').on('mousedown touchstart', '.nudge', function(e) {
// check if already existing to prevent issues
var timerId_ = $(this).data('timerId');
var intervalId_ = $(this).data('intervalId');
if (timerId_ || intervalId_) {
return;
}

var that = this;
var timerId = setTimeout(function() {
// creat timer
Expand Down Expand Up @@ -1119,7 +1136,8 @@ var setEvents = function(){
callNudgeAction(this, 1);
clearTimeout(timerId);
$(this).data('timerId', null);
} else if (intervalId) { // Long press activated
}
if (intervalId) { // Long press activated
clearInterval(intervalId);
$(this).data('intervalId', null);
// should make sibling <input> inactive
Expand Down

0 comments on commit 1215270

Please sign in to comment.