/ Published in: JavaScript
Expand |
Embed | Plain Text
// Author: Piotr Filipek // Script: SoQ 4.0.0 $.Wheel = []; $.e.wheel = function(a1, a2){ var time = (new Date()).getTime() var a3 = 0; $.Wheel[time] = 0; $(this).on("mousewheel", function(e){ if(e.wheel == 1){ if($.Wheel[time] != a1.length-1) ++$.Wheel[time]; } else { if($.Wheel[time] != 0) --$.Wheel[time]; } a3 = $.Wheel[time]%a1.length; $.func(a2).call(this, a1, a3, a1[a3]); }); }; // Ex. 1 - font size $("#size").wheel([15, 20, 25, 30], function(a1, a2){ $(this).css("font-size", a1[a2]); }); // Ex. 2 - colors $("#color").wheel(["green", "red", "blue", "black"], function(a1, a2){ $(this).css("background", a1[a2]); });
You need to login to post a comment.
