500ms delay for sliders on touch devices

This commit is contained in:
RossAscends
2023-08-24 03:34:20 +09:00
parent 2c58f9d903
commit 6c56fb0a6d
2 changed files with 28 additions and 2 deletions

View File

@ -8008,6 +8008,32 @@ $(document).ready(function () {
////////////////// OPTIMIZED RANGE SLIDER LISTENERS//////////////// ////////////////// OPTIMIZED RANGE SLIDER LISTENERS////////////////
var sliderLocked = true;
var sliderTimer;
$("input[type='range']").on("touchstart", function () {
// Unlock the slider after 500ms
sliderTimer = setTimeout(function () {
sliderLocked = false;
}, 500);
});
$("input[type='range']").on("touchend", function () {
clearTimeout(sliderTimer);
$(this).css('background-color', '')
sliderLocked = true
});
$("input[type='range']").on("touchmove", function (event) {
if (sliderLocked) {
event.preventDefault();
}
else {
$(this).css('background-color', 'var(--SmartThemeQuoteColor)')
}
});
const sliders = [ const sliders = [
{ {
sliderId: "#amount_gen", sliderId: "#amount_gen",