mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-13 01:30:31 +08:00
pikvm/pikvm#506: improved delayed sliders behaviour
This commit is contained in:
parent
60e2a38dcd
commit
73685123cc
@ -131,6 +131,8 @@ export var tools = new function() {
|
|||||||
return {
|
return {
|
||||||
"setOnUpDelayed": function(el, delay, execute_callback) {
|
"setOnUpDelayed": function(el, delay, execute_callback) {
|
||||||
el.__execution_timer = null;
|
el.__execution_timer = null;
|
||||||
|
el.__pressed = false;
|
||||||
|
el.__postponed = null;
|
||||||
|
|
||||||
let clear_timer = function() {
|
let clear_timer = function() {
|
||||||
if (el.__execution_timer) {
|
if (el.__execution_timer) {
|
||||||
@ -141,6 +143,7 @@ export var tools = new function() {
|
|||||||
|
|
||||||
el.onmousedown = el.ontouchstart = function() {
|
el.onmousedown = el.ontouchstart = function() {
|
||||||
clear_timer();
|
clear_timer();
|
||||||
|
el.__pressed = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
el.onmouseup = el.ontouchend = function(event) {
|
el.onmouseup = el.ontouchend = function(event) {
|
||||||
@ -148,6 +151,11 @@ export var tools = new function() {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
clear_timer();
|
clear_timer();
|
||||||
el.__execution_timer = setTimeout(function() {
|
el.__execution_timer = setTimeout(function() {
|
||||||
|
el.__pressed = false;
|
||||||
|
if (el.__postponed !== null) {
|
||||||
|
self.slider.setValue(el, el.__postponed);
|
||||||
|
el.__postponed = null;
|
||||||
|
}
|
||||||
execute_callback(value);
|
execute_callback(value);
|
||||||
}, delay);
|
}, delay);
|
||||||
};
|
};
|
||||||
@ -165,11 +173,15 @@ export var tools = new function() {
|
|||||||
},
|
},
|
||||||
"setValue": function(el, value) {
|
"setValue": function(el, value) {
|
||||||
if (el.value != value) {
|
if (el.value != value) {
|
||||||
|
if (el.__pressed) {
|
||||||
|
el.__postponed = value;
|
||||||
|
} else {
|
||||||
el.value = value;
|
el.value = value;
|
||||||
if (el.__display_callback) {
|
if (el.__display_callback) {
|
||||||
el.__display_callback(value);
|
el.__display_callback(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"getValue": function(el) {
|
"getValue": function(el) {
|
||||||
if (el.step % 1 === 0) {
|
if (el.step % 1 === 0) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user