noUIslider modded to limit it move rate (cpu friendly)

This commit is contained in:
jean-emmanuel 2015-04-09 20:16:27 +02:00 • committed by Jean-Emmanuel
parent 93259e9c60
commit 6596f7e5a0
7 changed files with 36 additions and 13 deletions

View file

@ -1,5 +1,6 @@
/*! noUiSlider - 7.0.3 - 2014-09-11 16:30:11 */
/* With rate mod @ 1561 (Jean-Emmanuel Doucet) */
(function(){
'use strict';
@ -19,6 +20,8 @@ var
'undo'
];
// General
// Reverse a string
@ -1555,9 +1558,26 @@ function closure ( target, options, originalOptions ){
callback ( e, data );
});
}
// BIG FAT & UGLY MOD
// Limit move's rate for better performances
// It skips events, but we don't need that much precision here
function move (event, data) {
window.now = +new Date;
if (window.last && window.now - window.last > 30) {
window.last = window.now;
moveP(event, data);
} else if (!window.last) {
// first call
window.last = window.now;
moveP(event, data);
}
}
// Handle movement on document for handle and range drag.
function move ( event, data ) {
function moveP ( event, data ) {
var handles = data.handles || $Handles, positions, state = false,
proposal = ((event.calcPoint - data.start) * 100) / baseSize(),
@ -1576,6 +1596,7 @@ function closure ( target, options, originalOptions ){
if ( state ) {
fireEvents(['slide']);
}
}
// Unbind move events on document, call callbacks.