EasyUI Forum
June 16, 2024, 11:19:48 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: NumberSpinner Long Press Increase/Decrease Values  (Read 1395 times)
poeziafree
Jr. Member
**
Posts: 69


View Profile Email
« on: June 24, 2023, 11:08:18 PM »

Hello,

How can we extend the NumberSpinner to allow the long press key to increase or decrease values without clicking the button each time?

Regards,
Logged
jarry
Administrator
Hero Member
*****
Posts: 2265


View Profile Email
« Reply #1 on: June 26, 2023, 08:41:08 PM »

Please refer to this code.
Code:
var ns = $('#ns');
function doSpin(target, down) {
var opts = $.data(target, 'numberspinner').options;
var v = parseFloat($(target).numberbox('getValue') || opts.value) || 0;
if (down) {
v -= opts.increment;
} else {
v += opts.increment;
}
$(target).numberbox('setValue', v);
}

var opts = ns.numberspinner('options');
var icon = ns.numberspinner('getIcon', 0);
var spin = icon.find('.spinner-arrow');
spin.on('mousedown.spinner', function (e) {
var down = $(e.target).closest('.spinner-arrow').hasClass('spinner-button-bottom');
opts.longTimer1 = setInterval(function () {
doSpin(ns[0],down);
}, 100)
}).on('mouseup.spinner', function (e) {
clearInterval(opts.longTimer1)
}).on('mouseout.spinner', function (e) {
clearInterval(opts.longTimer1)
})
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!