pageslider.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * Created by sunlan on 14/10/27.
  3. */
  4. !function($) {
  5. var a = 10;
  6. $(document).on("touchmove", function(a) {
  7. a.preventDefault()
  8. }),
  9. $.fn.pageSlider = function() {
  10. for (var b = this, c = {
  11. length: b.length,
  12. currentIndex: 0
  13. }, d = {
  14. next: function() {
  15. if (c.currentIndex + 1 < c.length) {
  16. var a = b[c.currentIndex];
  17. $(a).removeClass("slidedown in").addClass("slidedown out reverse"), c.currentIndex++, $(b[c.currentIndex - 1]).trigger("leave"), $(b[c.currentIndex]).trigger("enter", [{
  18. index: c.currentIndex
  19. }])
  20. }
  21. },
  22. prev: function() {
  23. if (c.currentIndex > 0) {
  24. var a = b[c.currentIndex - 1];
  25. $(a).removeClass("slidedown out reverse").addClass("slidedown in"), c.currentIndex--, $(b[c.currentIndex + 1]).trigger("leave"), $(b[c.currentIndex]).trigger("enter", [{
  26. index: c.currentIndex
  27. }])
  28. }
  29. }
  30. }, e = c.length - 1; e >= 0; e--) $(b[e]).css("z-index", a + c.length - e);
  31. return b.css("visibility", "visible"), b.on("swipeUp", function() {
  32. d.next()
  33. }).on("swipeDown", function() {
  34. d.prev()
  35. }).on("mousewheel", function() {
  36. var a = new Date;
  37. return function(b) {
  38. var c = b.wheelDelta,
  39. e = new Date,
  40. f = e - a;
  41. a = e, c && f > 250 && (0 > c ? d.next() : d.prev())
  42. }
  43. }()), this
  44. }
  45. }(Zepto)