Posted By

Piotrek290 on 07/08/10


Tagged

scroll select array wheel


Versions (?)

Next element when wheel is scrolling


 / Published in: JavaScript
 

  1. // Author: Piotr Filipek
  2. // Script: SoQ 4.0.0
  3.  
  4. $.Wheel = [];
  5. $.e.wheel = function(a1, a2){
  6. var time = (new Date()).getTime()
  7. var a3 = 0;
  8.  
  9. $.Wheel[time] = 0;
  10.  
  11. $(this).on("mousewheel", function(e){
  12. if(e.wheel == 1){
  13. if($.Wheel[time] != a1.length-1) ++$.Wheel[time];
  14. } else {
  15. if($.Wheel[time] != 0) --$.Wheel[time];
  16. }
  17.  
  18. a3 = $.Wheel[time]%a1.length;
  19. $.func(a2).call(this, a1, a3, a1[a3]);
  20. });
  21. };
  22.  
  23. // Ex. 1 - font size
  24. $("#size").wheel([15, 20, 25, 30], function(a1, a2){
  25. $(this).css("font-size", a1[a2]);
  26. });
  27.  
  28. // Ex. 2 - colors
  29. $("#color").wheel(["green", "red", "blue", "black"], function(a1, a2){
  30. $(this).css("background", a1[a2]);
  31. });

Report this snippet  

You need to login to post a comment.