pull-up-down.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. $.fn.initScroll = function (opt) {
  2. var id = this.find('.scroll-wrapper').attr('id'),
  3. pullDown = opt && (opt.pullDown===false?false:true),
  4. pullUp = opt && (opt.pullUp===false?false:true);
  5. var scroller = new IScrollPullUpDown(id,$.extend(true,{},{
  6. probeType:2,
  7. bounceTime: 250,
  8. bounceEasing: 'quadratic',
  9. mouseWheel:false,
  10. scrollbars:true,
  11. fadeScrollbars:true,
  12. interactiveScrollbars:false,
  13. click: true,
  14. preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT|CANVAS)$/ }
  15. },opt),pullDown?pullDownAction:null,pullUp?pullUpAction:null);
  16. //下拉刷新
  17. function pullDownAction(theScrollerTemp) {
  18. $(".pullDown").show();
  19. if(opt && opt.pullDownAction && $.isFunction(opt.pullDownAction)) {
  20. setTimeout(function () {
  21. opt.pullDownAction();
  22. }, 1000);
  23. }
  24. }
  25. //上拉加载数据
  26. function pullUpAction(theScrollerTemp) {
  27. if(opt && opt.pullUp===false) {
  28. return;
  29. }
  30. $(".pullUp").show();
  31. if(opt && opt.pullUpAction && $.isFunction(opt.pullUpAction)) {
  32. setTimeout(function () {
  33. opt.pullUpAction();
  34. }, 1000);
  35. }
  36. }
  37. document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
  38. return scroller;
  39. }