1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- export const int = (number) => {
- if (number === '') {
- return 0
- }
- return parseInt(number, 10)
- }
- export const innerWidth = (node) => {
- let width = node.clientWidth;
- const computedStyle = node.style
- width -= int(computedStyle.paddingLeft);
- width -= int(computedStyle.paddingRight);
- return width;
- }
- export const outerWidth = (node) => {
- let width = node.clientWidth;
- const computedStyle = node.style
- width += int(computedStyle.borderLeftWidth);
- width += int(computedStyle.borderRightWidth);
- return width;
- }
- export const innerHeight = (node) => {
- let height = node.clientHeight;
- const computedStyle = node.style
- height -= int(computedStyle.paddingTop);
- height -= int(computedStyle.paddingBottom);
- return height;
- }
- export const outerHeight = (node) => {
- let height = node.clientHeight;
- const computedStyle = node.style
- height += int(computedStyle.borderTopWidth);
- height += int(computedStyle.borderBottomWidth);
- return height;
- }
- export const parseBounds = (bounds) => {
- return {
- left: bounds.left,
- top: bounds.top,
- right: bounds.right,
- bottom: bounds.bottom
- }
- }
- export const isNumber = (things) => {
- return typeof things === 'number' ? true : false
- }
- export const getDataSet = (children) => {
- return children.map((child) => {
- return { ...child.props['data-set'], isUserMove: true, key: child.key, }
- })
- }
- export const stringJoin = (source, join) => {
- return source + (join ? ` ${join}` : '')
- }
|