utils.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. "use strict";
  2. var __assign = (this && this.__assign) || Object.assign || function(t) {
  3. for (var s, i = 1, n = arguments.length; i < n; i++) {
  4. s = arguments[i];
  5. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  6. t[p] = s[p];
  7. }
  8. return t;
  9. };
  10. Object.defineProperty(exports, "__esModule", { value: true });
  11. exports.int = function (number) {
  12. if (number === '' || number === null) {
  13. return 0;
  14. }
  15. return parseInt(number, 10);
  16. };
  17. exports.innerWidth = function (node) {
  18. var width = node.clientWidth;
  19. var computedStyle = node.style;
  20. width -= exports.int(computedStyle.paddingLeft);
  21. width -= exports.int(computedStyle.paddingRight);
  22. return width;
  23. };
  24. exports.outerWidth = function (node) {
  25. var width = node.clientWidth;
  26. var computedStyle = node.style;
  27. width += exports.int(computedStyle.borderLeftWidth);
  28. width += exports.int(computedStyle.borderRightWidth);
  29. return width;
  30. };
  31. exports.innerHeight = function (node) {
  32. var height = node.clientHeight;
  33. var computedStyle = node.style;
  34. height -= exports.int(computedStyle.paddingTop);
  35. height -= exports.int(computedStyle.paddingBottom);
  36. return height;
  37. };
  38. exports.outerHeight = function (node) {
  39. var height = node.clientHeight;
  40. var computedStyle = node.style;
  41. height += exports.int(computedStyle.borderTopWidth);
  42. height += exports.int(computedStyle.borderBottomWidth);
  43. return height;
  44. };
  45. exports.parseBounds = function (bounds) {
  46. return {
  47. left: bounds.left,
  48. top: bounds.top,
  49. right: bounds.right,
  50. bottom: bounds.bottom
  51. };
  52. };
  53. exports.isNumber = function (things) {
  54. return typeof things === 'number' ? true : false;
  55. };
  56. exports.getDataSet = function (children) {
  57. return children.map(function (child) {
  58. return __assign({}, child.props['data-set'], { isUserMove: true, key: child.key });
  59. });
  60. };
  61. exports.stringJoin = function (source, join) {
  62. return source + (join ? " " + join : '');
  63. };