utils.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. export var int = function int(number) {
  2. if (number === '') {
  3. return 0;
  4. }
  5. return parseInt(number, 10);
  6. };
  7. export var innerWidth = function innerWidth(node) {
  8. var width = node.clientWidth;
  9. var computedStyle = node.style;
  10. width -= int(computedStyle.paddingLeft);
  11. width -= int(computedStyle.paddingRight);
  12. return width;
  13. };
  14. export var outerWidth = function outerWidth(node) {
  15. var width = node.clientWidth;
  16. var computedStyle = node.style;
  17. width += int(computedStyle.borderLeftWidth);
  18. width += int(computedStyle.borderRightWidth);
  19. return width;
  20. };
  21. export var innerHeight = function innerHeight(node) {
  22. var height = node.clientHeight;
  23. var computedStyle = node.style;
  24. height -= int(computedStyle.paddingTop);
  25. height -= int(computedStyle.paddingBottom);
  26. return height;
  27. };
  28. export var outerHeight = function outerHeight(node) {
  29. var height = node.clientHeight;
  30. var computedStyle = node.style;
  31. height += int(computedStyle.borderTopWidth);
  32. height += int(computedStyle.borderBottomWidth);
  33. return height;
  34. };
  35. export var parseBounds = function parseBounds(bounds) {
  36. return {
  37. left: bounds.left,
  38. top: bounds.top,
  39. right: bounds.right,
  40. bottom: bounds.bottom
  41. };
  42. };
  43. export var isNumber = function isNumber(things) {
  44. return typeof things === 'number' ? true : false;
  45. };
  46. ;
  47. var _temp = function () {
  48. if (typeof __REACT_HOT_LOADER__ === 'undefined') {
  49. return;
  50. }
  51. __REACT_HOT_LOADER__.register(int, 'int', 'app/src/utils.js');
  52. __REACT_HOT_LOADER__.register(innerWidth, 'innerWidth', 'app/src/utils.js');
  53. __REACT_HOT_LOADER__.register(outerWidth, 'outerWidth', 'app/src/utils.js');
  54. __REACT_HOT_LOADER__.register(innerHeight, 'innerHeight', 'app/src/utils.js');
  55. __REACT_HOT_LOADER__.register(outerHeight, 'outerHeight', 'app/src/utils.js');
  56. __REACT_HOT_LOADER__.register(parseBounds, 'parseBounds', 'app/src/utils.js');
  57. __REACT_HOT_LOADER__.register(isNumber, 'isNumber', 'app/src/utils.js');
  58. }();
  59. ;