utils.js 1.9 KB

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