3 Star 56 Fork 13

Yaohaixiao/dom.js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
sizes.js 1.30 KB
一键复制 编辑 原始数据 按行查看 历史
Yaohaixiao 提交于 2023-10-12 16:04 . chore: 调整单测代码
import _getElementSizes from './_getElementSizes'
import innerHeight from './innerHeight'
import innerWidth from './innerWidth'
import outerHeight from './outerHeight'
import outerWidth from './outerWidth'
/**
* 获取 DOM 节点的相关尺寸信息,返回相关尺寸数据的对象。
* ========================================================================
* @method sizes
* @param {HTMLElement} el
* @return {Object|Boolean}
*/
const sizes = (el) => {
const elSizes = _getElementSizes(el)
if (!elSizes) {
return false
}
return {
offsetHeight: elSizes.offsetHeight,
offsetWidth: elSizes.offsetWidth,
innerHeight: innerHeight(el),
innerWidth: innerWidth(el),
outerHeight: outerHeight(el),
outerWidth: outerWidth(el),
margin: {
top: elSizes.marginTop,
right: elSizes.marginRight,
bottom: elSizes.marginBottom,
left: elSizes.marginLeft
},
border: {
top: elSizes.borderTop,
right: elSizes.borderRight,
bottom: elSizes.borderBottom,
left: elSizes.borderLeft
},
padding: {
top: elSizes.paddingTop,
right: elSizes.paddingRight,
bottom: elSizes.paddingBottom,
left: elSizes.paddingLeft
},
rect: elSizes.rect
}
}
export default sizes
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/yaohaixiao/dom.js.git
git@gitee.com:yaohaixiao/dom.js.git
yaohaixiao
dom.js
dom.js
main

搜索帮助