Comparing version 1.2.1 to 1.3.0
@@ -78,14 +78,2 @@ /** | ||
/* | ||
* align node | ||
* @param {Element} node current dom node | ||
* @param {Object} align align config | ||
* | ||
* @example | ||
* { | ||
* node: null, // 参考元素, falsy 或 window 为可视区域, 'trigger' 为触发元素, 其他为指定元素 | ||
* points: ['cc','cc'], // ['tr', 'tl'] 表示 overlay 的 tr 与参考节点的 tl 对齐 | ||
* offset: [0, 0] // 有效值为 [n, m] | ||
* } | ||
*/ | ||
function domAlign(el, refNode, align) { | ||
@@ -96,2 +84,4 @@ var points = align.points; | ||
var overflow = align.overflow; | ||
var target = align.target || refNode; | ||
var source = align.source || el; | ||
offset = [].concat(offset); | ||
@@ -104,7 +94,7 @@ targetOffset = [].concat(targetOffset); | ||
// 当前节点可以被放置的显示区域 | ||
var visibleRect = (0, _getVisibleRectForElement2['default'])(el); | ||
var visibleRect = (0, _getVisibleRectForElement2['default'])(source); | ||
// 当前节点所占的区域, left/top/width/height | ||
var elRegion = (0, _getRegion2['default'])(el); | ||
var elRegion = (0, _getRegion2['default'])(source); | ||
// 参照节点所占的区域, left/top/width/height | ||
var refNodeRegion = (0, _getRegion2['default'])(refNode); | ||
var refNodeRegion = (0, _getRegion2['default'])(target); | ||
// 将 offset 转换成数值,支持百分比 | ||
@@ -170,7 +160,7 @@ normalizeOffset(offset, elRegion); | ||
if (newElRegion.width !== elRegion.width) { | ||
_utils2['default'].css(el, 'width', el.width() + newElRegion.width - elRegion.width); | ||
_utils2['default'].css(source, 'width', source.width() + newElRegion.width - elRegion.width); | ||
} | ||
if (newElRegion.height !== elRegion.height) { | ||
_utils2['default'].css(el, 'height', el.height() + newElRegion.height - elRegion.height); | ||
_utils2['default'].css(source, 'height', source.height() + newElRegion.height - elRegion.height); | ||
} | ||
@@ -182,3 +172,3 @@ | ||
// 例如 <div 'relative'><el absolute></div> | ||
_utils2['default'].offset(el, { | ||
_utils2['default'].offset(source, { | ||
left: newElRegion.left, | ||
@@ -185,0 +175,0 @@ top: newElRegion.top |
{ | ||
"name": "dom-align", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Align DOM Node Flexibly ", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35382
830