diff options
author | Maxim Devaev <[email protected]> | 2021-10-23 08:42:13 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2021-10-23 08:42:13 +0300 |
commit | 73685123ccc13d4f72da2845d9172ef55ae74d68 (patch) | |
tree | e74aa73a4269decf4daf33855be10f754994a6b8 /web/share | |
parent | 60e2a38dcd821699c2b8454e3e4dab08708b8ba4 (diff) |
pikvm/pikvm#506: improved delayed sliders behaviour
Diffstat (limited to 'web/share')
-rw-r--r-- | web/share/js/tools.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/web/share/js/tools.js b/web/share/js/tools.js index 79dbd432..18f06a23 100644 --- a/web/share/js/tools.js +++ b/web/share/js/tools.js @@ -131,6 +131,8 @@ export var tools = new function() { return { "setOnUpDelayed": function(el, delay, execute_callback) { el.__execution_timer = null; + el.__pressed = false; + el.__postponed = null; let clear_timer = function() { if (el.__execution_timer) { @@ -141,6 +143,7 @@ export var tools = new function() { el.onmousedown = el.ontouchstart = function() { clear_timer(); + el.__pressed = true; }; el.onmouseup = el.ontouchend = function(event) { @@ -148,6 +151,11 @@ export var tools = new function() { event.preventDefault(); clear_timer(); el.__execution_timer = setTimeout(function() { + el.__pressed = false; + if (el.__postponed !== null) { + self.slider.setValue(el, el.__postponed); + el.__postponed = null; + } execute_callback(value); }, delay); }; @@ -165,9 +173,13 @@ export var tools = new function() { }, "setValue": function(el, value) { if (el.value != value) { - el.value = value; - if (el.__display_callback) { - el.__display_callback(value); + if (el.__pressed) { + el.__postponed = value; + } else { + el.value = value; + if (el.__display_callback) { + el.__display_callback(value); + } } } }, |