dom-lib.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import $ from "jquery";
  2. const $window = $(window);
  3. const $doc = $(document);
  4. const $$ = {
  5. $window: $window,
  6. $doc: $doc,
  7. getHeight: function (node) {
  8. return $(node).innerHeight();
  9. },
  10. getWidth: function (node) {
  11. return $(node).innerWidth();
  12. },
  13. animate: {
  14. left: function (el, left) {
  15. },
  16. top: function (el, top) {
  17. },
  18. slideDown: function ($el, cb) {
  19. let h = $el.height();
  20. let cacheH = 0;
  21. let timer = setInterval(function () {
  22. $el.height(cacheH);
  23. cacheH++;
  24. if(cacheH >= h) {
  25. clearInterval(timer);
  26. cb && cb();
  27. }
  28. }, 20);
  29. },
  30. slideUp: function ($el, cb) {
  31. let h = $el.height();
  32. let cacheH = 0;
  33. let timer = setInterval(function () {
  34. $el.height(cacheH);
  35. cacheH--;
  36. if(cacheH <= 0) {
  37. clearInterval(timer);
  38. $el.height(h);
  39. cb && cb();
  40. }
  41. }, 20);
  42. }
  43. }
  44. }
  45. module.exports = $$;