calebasse / calebasse / static / js / calebasse.mousewheel.js @ 37cdace1
1 |
$(function () { |
---|---|
2 |
$('body').on('mousewheel', '.mousewheel', function (event, delta) { |
3 |
var increment = parseInt($(this).data('mousewheel-increment')); |
4 |
var lo = parseInt($(this).data('mousewheel-lo')) || 0; |
5 |
var hi = parseInt($(this).data('mousewheel-hi')) || 1000; |
6 |
var $this = $(this); |
7 |
if (delta < 0) { |
8 |
increment = -increment; |
9 |
}
|
10 |
if ($this.is('input')) { |
11 |
value = $this.val(); |
12 |
} else { |
13 |
value = $this.text(); |
14 |
}
|
15 |
try { |
16 |
value = parseInt(value || 0); |
17 |
} catch (e) { |
18 |
value = 0; |
19 |
}
|
20 |
value += increment; |
21 |
if (value < lo) { |
22 |
value = lo; |
23 |
} else if (value > hi) { |
24 |
value = hi; |
25 |
}
|
26 |
if ($this.is('input')) { |
27 |
$this.val(value); |
28 |
} else { |
29 |
$this.html(value); |
30 |
}
|
31 |
return false; |
32 |
});
|
33 |
});
|