index.js 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vendorPrefix;
  4. var jsCssMap = {
  5. Webkit: '-webkit-',
  6. Moz: '-moz-',
  7. // IE did it wrong again ...
  8. ms: '-ms-',
  9. O: '-o-'
  10. };
  11. function getVendorPrefix() {
  12. if (vendorPrefix !== undefined) {
  13. return vendorPrefix;
  14. }
  15. vendorPrefix = '';
  16. var style = document.createElement('p').style;
  17. var testProp = 'Transform';
  18. for (var key in jsCssMap) {
  19. if (key + testProp in style) {
  20. vendorPrefix = key;
  21. }
  22. }
  23. return vendorPrefix;
  24. }
  25. function getTransitionName() {
  26. return getVendorPrefix() ? "".concat(getVendorPrefix(), "TransitionProperty") : 'transitionProperty';
  27. }
  28. function getTransformName() {
  29. return getVendorPrefix() ? "".concat(getVendorPrefix(), "Transform") : 'transform';
  30. }
  31. function setTransitionProperty(node, value) {
  32. var name = getTransitionName();
  33. if (name) {
  34. node.style[name] = value;
  35. if (name !== 'transitionProperty') {
  36. node.style.transitionProperty = value;
  37. }
  38. }
  39. }
  40. function setTransform(node, value) {
  41. var name = getTransformName();
  42. if (name) {
  43. node.style[name] = value;
  44. if (name !== 'transform') {
  45. node.style.transform = value;
  46. }
  47. }
  48. }
  49. function getTransitionProperty(node) {
  50. return node.style.transitionProperty || node.style[getTransitionName()];
  51. }
  52. function getTransformXY(node) {
  53. var style = window.getComputedStyle(node, null);
  54. var transform = style.getPropertyValue('transform') || style.getPropertyValue(getTransformName());
  55. if (transform && transform !== 'none') {
  56. var matrix = transform.replace(/[^0-9\-.,]/g, '').split(',');
  57. return {
  58. x: parseFloat(matrix[12] || matrix[4], 0),
  59. y: parseFloat(matrix[13] || matrix[5], 0)
  60. };
  61. }
  62. return {
  63. x: 0,
  64. y: 0
  65. };
  66. }
  67. var matrix2d = /matrix\((.*)\)/;
  68. var matrix3d = /matrix3d\((.*)\)/;
  69. function setTransformXY(node, xy) {
  70. var style = window.getComputedStyle(node, null);
  71. var transform = style.getPropertyValue('transform') || style.getPropertyValue(getTransformName());
  72. if (transform && transform !== 'none') {
  73. var arr;
  74. var match2d = transform.match(matrix2d);
  75. if (match2d) {
  76. match2d = match2d[1];
  77. arr = match2d.split(',').map(function (item) {
  78. return parseFloat(item, 10);
  79. });
  80. arr[4] = xy.x;
  81. arr[5] = xy.y;
  82. setTransform(node, "matrix(".concat(arr.join(','), ")"));
  83. } else {
  84. var match3d = transform.match(matrix3d)[1];
  85. arr = match3d.split(',').map(function (item) {
  86. return parseFloat(item, 10);
  87. });
  88. arr[12] = xy.x;
  89. arr[13] = xy.y;
  90. setTransform(node, "matrix3d(".concat(arr.join(','), ")"));
  91. }
  92. } else {
  93. setTransform(node, "translateX(".concat(xy.x, "px) translateY(").concat(xy.y, "px) translateZ(0)"));
  94. }
  95. }
  96. function _typeof(obj) {
  97. "@babel/helpers - typeof";
  98. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
  99. return typeof obj;
  100. } : function (obj) {
  101. return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  102. }, _typeof(obj);
  103. }
  104. var RE_NUM = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source;
  105. var getComputedStyleX;
  106. // https://stackoverflow.com/a/3485654/3040605
  107. function forceRelayout(elem) {
  108. var originalStyle = elem.style.display;
  109. elem.style.display = 'none';
  110. elem.offsetHeight; // eslint-disable-line
  111. elem.style.display = originalStyle;
  112. }
  113. function css(el, name, v) {
  114. var value = v;
  115. if (_typeof(name) === 'object') {
  116. for (var i in name) {
  117. if (name.hasOwnProperty(i)) {
  118. css(el, i, name[i]);
  119. }
  120. }
  121. return undefined;
  122. }
  123. if (typeof value !== 'undefined') {
  124. if (typeof value === 'number') {
  125. value = "".concat(value, "px");
  126. }
  127. el.style[name] = value;
  128. return undefined;
  129. }
  130. return getComputedStyleX(el, name);
  131. }
  132. function getClientPosition(elem) {
  133. var box;
  134. var x;
  135. var y;
  136. var doc = elem.ownerDocument;
  137. var body = doc.body;
  138. var docElem = doc && doc.documentElement;
  139. // 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式
  140. box = elem.getBoundingClientRect();
  141. // 注:jQuery 还考虑减去 docElem.clientLeft/clientTop
  142. // 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确
  143. // 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin
  144. x = Math.floor(box.left);
  145. y = Math.floor(box.top);
  146. // In IE, most of the time, 2 extra pixels are added to the top and left
  147. // due to the implicit 2-pixel inset border. In IE6/7 quirks mode and
  148. // IE6 standards mode, this border can be overridden by setting the
  149. // document element's border to zero -- thus, we cannot rely on the
  150. // offset always being 2 pixels.
  151. // In quirks mode, the offset can be determined by querying the body's
  152. // clientLeft/clientTop, but in standards mode, it is found by querying
  153. // the document element's clientLeft/clientTop. Since we already called
  154. // getClientBoundingRect we have already forced a reflow, so it is not
  155. // too expensive just to query them all.
  156. // ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的
  157. // 窗口边框标准是设 documentElement ,quirks 时设置 body
  158. // 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去
  159. // 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置
  160. // 标准 ie 下 docElem.clientTop 就是 border-top
  161. // ie7 html 即窗口边框改变不了。永远为 2
  162. // 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0
  163. x -= docElem.clientLeft || body.clientLeft || 0;
  164. y -= docElem.clientTop || body.clientTop || 0;
  165. return {
  166. left: x,
  167. top: y
  168. };
  169. }
  170. function getScroll(w, top) {
  171. var ret = w["page".concat(top ? 'Y' : 'X', "Offset")];
  172. var method = "scroll".concat(top ? 'Top' : 'Left');
  173. if (typeof ret !== 'number') {
  174. var d = w.document;
  175. // ie6,7,8 standard mode
  176. ret = d.documentElement[method];
  177. if (typeof ret !== 'number') {
  178. // quirks mode
  179. ret = d.body[method];
  180. }
  181. }
  182. return ret;
  183. }
  184. function getScrollLeft(w) {
  185. return getScroll(w);
  186. }
  187. function getScrollTop(w) {
  188. return getScroll(w, true);
  189. }
  190. function getOffset(el) {
  191. var pos = getClientPosition(el);
  192. var doc = el.ownerDocument;
  193. var w = doc.defaultView || doc.parentWindow;
  194. pos.left += getScrollLeft(w);
  195. pos.top += getScrollTop(w);
  196. return pos;
  197. }
  198. /**
  199. * A crude way of determining if an object is a window
  200. * @member util
  201. */
  202. function isWindow(obj) {
  203. // must use == for ie8
  204. /* eslint eqeqeq:0 */
  205. return obj !== null && obj !== undefined && obj == obj.window;
  206. }
  207. function getDocument(node) {
  208. if (isWindow(node)) {
  209. return node.document;
  210. }
  211. if (node.nodeType === 9) {
  212. return node;
  213. }
  214. return node.ownerDocument;
  215. }
  216. function _getComputedStyle(elem, name, cs) {
  217. var computedStyle = cs;
  218. var val = '';
  219. var d = getDocument(elem);
  220. computedStyle = computedStyle || d.defaultView.getComputedStyle(elem, null);
  221. // https://github.com/kissyteam/kissy/issues/61
  222. if (computedStyle) {
  223. val = computedStyle.getPropertyValue(name) || computedStyle[name];
  224. }
  225. return val;
  226. }
  227. var _RE_NUM_NO_PX = new RegExp("^(".concat(RE_NUM, ")(?!px)[a-z%]+$"), 'i');
  228. var RE_POS = /^(top|right|bottom|left)$/;
  229. var CURRENT_STYLE = 'currentStyle';
  230. var RUNTIME_STYLE = 'runtimeStyle';
  231. var LEFT = 'left';
  232. var PX = 'px';
  233. function _getComputedStyleIE(elem, name) {
  234. // currentStyle maybe null
  235. // http://msdn.microsoft.com/en-us/library/ms535231.aspx
  236. var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name];
  237. // 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值
  238. // 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19
  239. // 在 ie 下不对,需要直接用 offset 方式
  240. // borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了
  241. // From the awesome hack by Dean Edwards
  242. // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
  243. // If we're not dealing with a regular pixel number
  244. // but a number that has a weird ending, we need to convert it to pixels
  245. // exclude left right for relativity
  246. if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) {
  247. // Remember the original values
  248. var style = elem.style;
  249. var left = style[LEFT];
  250. var rsLeft = elem[RUNTIME_STYLE][LEFT];
  251. // prevent flashing of content
  252. elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT];
  253. // Put in the new values to get a computed value out
  254. style[LEFT] = name === 'fontSize' ? '1em' : ret || 0;
  255. ret = style.pixelLeft + PX;
  256. // Revert the changed values
  257. style[LEFT] = left;
  258. elem[RUNTIME_STYLE][LEFT] = rsLeft;
  259. }
  260. return ret === '' ? 'auto' : ret;
  261. }
  262. if (typeof window !== 'undefined') {
  263. getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE;
  264. }
  265. function getOffsetDirection(dir, option) {
  266. if (dir === 'left') {
  267. return option.useCssRight ? 'right' : dir;
  268. }
  269. return option.useCssBottom ? 'bottom' : dir;
  270. }
  271. function oppositeOffsetDirection(dir) {
  272. if (dir === 'left') {
  273. return 'right';
  274. } else if (dir === 'right') {
  275. return 'left';
  276. } else if (dir === 'top') {
  277. return 'bottom';
  278. } else if (dir === 'bottom') {
  279. return 'top';
  280. }
  281. }
  282. // 设置 elem 相对 elem.ownerDocument 的坐标
  283. function setLeftTop(elem, offset, option) {
  284. // set position first, in-case top/left are set even on static elem
  285. if (css(elem, 'position') === 'static') {
  286. elem.style.position = 'relative';
  287. }
  288. var presetH = -999;
  289. var presetV = -999;
  290. var horizontalProperty = getOffsetDirection('left', option);
  291. var verticalProperty = getOffsetDirection('top', option);
  292. var oppositeHorizontalProperty = oppositeOffsetDirection(horizontalProperty);
  293. var oppositeVerticalProperty = oppositeOffsetDirection(verticalProperty);
  294. if (horizontalProperty !== 'left') {
  295. presetH = 999;
  296. }
  297. if (verticalProperty !== 'top') {
  298. presetV = 999;
  299. }
  300. var originalTransition = '';
  301. var originalOffset = getOffset(elem);
  302. if ('left' in offset || 'top' in offset) {
  303. originalTransition = getTransitionProperty(elem) || '';
  304. setTransitionProperty(elem, 'none');
  305. }
  306. if ('left' in offset) {
  307. elem.style[oppositeHorizontalProperty] = '';
  308. elem.style[horizontalProperty] = "".concat(presetH, "px");
  309. }
  310. if ('top' in offset) {
  311. elem.style[oppositeVerticalProperty] = '';
  312. elem.style[verticalProperty] = "".concat(presetV, "px");
  313. }
  314. // force relayout
  315. forceRelayout(elem);
  316. var old = getOffset(elem);
  317. var originalStyle = {};
  318. for (var key in offset) {
  319. if (offset.hasOwnProperty(key)) {
  320. var dir = getOffsetDirection(key, option);
  321. var preset = key === 'left' ? presetH : presetV;
  322. var off = originalOffset[key] - old[key];
  323. if (dir === key) {
  324. originalStyle[dir] = preset + off;
  325. } else {
  326. originalStyle[dir] = preset - off;
  327. }
  328. }
  329. }
  330. css(elem, originalStyle);
  331. // force relayout
  332. forceRelayout(elem);
  333. if ('left' in offset || 'top' in offset) {
  334. setTransitionProperty(elem, originalTransition);
  335. }
  336. var ret = {};
  337. for (var _key in offset) {
  338. if (offset.hasOwnProperty(_key)) {
  339. var _dir = getOffsetDirection(_key, option);
  340. var _off = offset[_key] - originalOffset[_key];
  341. if (_key === _dir) {
  342. ret[_dir] = originalStyle[_dir] + _off;
  343. } else {
  344. ret[_dir] = originalStyle[_dir] - _off;
  345. }
  346. }
  347. }
  348. css(elem, ret);
  349. }
  350. function setTransform$1(elem, offset) {
  351. var originalOffset = getOffset(elem);
  352. var originalXY = getTransformXY(elem);
  353. var resultXY = {
  354. x: originalXY.x,
  355. y: originalXY.y
  356. };
  357. if ('left' in offset) {
  358. resultXY.x = originalXY.x + offset.left - originalOffset.left;
  359. }
  360. if ('top' in offset) {
  361. resultXY.y = originalXY.y + offset.top - originalOffset.top;
  362. }
  363. setTransformXY(elem, resultXY);
  364. }
  365. function setOffset(elem, offset, option) {
  366. if (option.ignoreShake) {
  367. var oriOffset = getOffset(elem);
  368. var oLeft = oriOffset.left.toFixed(0);
  369. var oTop = oriOffset.top.toFixed(0);
  370. var tLeft = offset.left.toFixed(0);
  371. var tTop = offset.top.toFixed(0);
  372. if (oLeft === tLeft && oTop === tTop) {
  373. return;
  374. }
  375. }
  376. if (option.useCssRight || option.useCssBottom) {
  377. setLeftTop(elem, offset, option);
  378. } else if (option.useCssTransform && getTransformName() in document.body.style) {
  379. setTransform$1(elem, offset);
  380. } else {
  381. setLeftTop(elem, offset, option);
  382. }
  383. }
  384. function each(arr, fn) {
  385. for (var i = 0; i < arr.length; i++) {
  386. fn(arr[i]);
  387. }
  388. }
  389. function isBorderBoxFn(elem) {
  390. return getComputedStyleX(elem, 'boxSizing') === 'border-box';
  391. }
  392. var BOX_MODELS = ['margin', 'border', 'padding'];
  393. var CONTENT_INDEX = -1;
  394. var PADDING_INDEX = 2;
  395. var BORDER_INDEX = 1;
  396. var MARGIN_INDEX = 0;
  397. function swap(elem, options, callback) {
  398. var old = {};
  399. var style = elem.style;
  400. var name;
  401. // Remember the old values, and insert the new ones
  402. for (name in options) {
  403. if (options.hasOwnProperty(name)) {
  404. old[name] = style[name];
  405. style[name] = options[name];
  406. }
  407. }
  408. callback.call(elem);
  409. // Revert the old values
  410. for (name in options) {
  411. if (options.hasOwnProperty(name)) {
  412. style[name] = old[name];
  413. }
  414. }
  415. }
  416. function getPBMWidth(elem, props, which) {
  417. var value = 0;
  418. var prop;
  419. var j;
  420. var i;
  421. for (j = 0; j < props.length; j++) {
  422. prop = props[j];
  423. if (prop) {
  424. for (i = 0; i < which.length; i++) {
  425. var cssProp = void 0;
  426. if (prop === 'border') {
  427. cssProp = "".concat(prop).concat(which[i], "Width");
  428. } else {
  429. cssProp = prop + which[i];
  430. }
  431. value += parseFloat(getComputedStyleX(elem, cssProp)) || 0;
  432. }
  433. }
  434. }
  435. return value;
  436. }
  437. var domUtils = {
  438. getParent: function getParent(element) {
  439. var parent = element;
  440. do {
  441. if (parent.nodeType === 11 && parent.host) {
  442. parent = parent.host;
  443. } else {
  444. parent = parent.parentNode;
  445. }
  446. } while (parent && parent.nodeType !== 1 && parent.nodeType !== 9);
  447. return parent;
  448. }
  449. };
  450. each(['Width', 'Height'], function (name) {
  451. domUtils["doc".concat(name)] = function (refWin) {
  452. var d = refWin.document;
  453. return Math.max(
  454. // firefox chrome documentElement.scrollHeight< body.scrollHeight
  455. // ie standard mode : documentElement.scrollHeight> body.scrollHeight
  456. d.documentElement["scroll".concat(name)],
  457. // quirks : documentElement.scrollHeight 最大等于可视窗口多一点?
  458. d.body["scroll".concat(name)], domUtils["viewport".concat(name)](d));
  459. };
  460. domUtils["viewport".concat(name)] = function (win) {
  461. // pc browser includes scrollbar in window.innerWidth
  462. var prop = "client".concat(name);
  463. var doc = win.document;
  464. var body = doc.body;
  465. var documentElement = doc.documentElement;
  466. var documentElementProp = documentElement[prop];
  467. // 标准模式取 documentElement
  468. // backcompat 取 body
  469. return doc.compatMode === 'CSS1Compat' && documentElementProp || body && body[prop] || documentElementProp;
  470. };
  471. });
  472. /*
  473. 得到元素的大小信息
  474. @param elem
  475. @param name
  476. @param {String} [extra] 'padding' : (css width) + padding
  477. 'border' : (css width) + padding + border
  478. 'margin' : (css width) + padding + border + margin
  479. */
  480. function getWH(elem, name, ex) {
  481. var extra = ex;
  482. if (isWindow(elem)) {
  483. return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem);
  484. } else if (elem.nodeType === 9) {
  485. return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem);
  486. }
  487. var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];
  488. var borderBoxValue = name === 'width' ? Math.floor(elem.getBoundingClientRect().width) : Math.floor(elem.getBoundingClientRect().height);
  489. var isBorderBox = isBorderBoxFn(elem);
  490. var cssBoxValue = 0;
  491. if (borderBoxValue === null || borderBoxValue === undefined || borderBoxValue <= 0) {
  492. borderBoxValue = undefined;
  493. // Fall back to computed then un computed css if necessary
  494. cssBoxValue = getComputedStyleX(elem, name);
  495. if (cssBoxValue === null || cssBoxValue === undefined || Number(cssBoxValue) < 0) {
  496. cssBoxValue = elem.style[name] || 0;
  497. }
  498. // Normalize '', auto, and prepare for extra
  499. cssBoxValue = Math.floor(parseFloat(cssBoxValue)) || 0;
  500. }
  501. if (extra === undefined) {
  502. extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX;
  503. }
  504. var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox;
  505. var val = borderBoxValue || cssBoxValue;
  506. if (extra === CONTENT_INDEX) {
  507. if (borderBoxValueOrIsBorderBox) {
  508. return val - getPBMWidth(elem, ['border', 'padding'], which);
  509. }
  510. return cssBoxValue;
  511. } else if (borderBoxValueOrIsBorderBox) {
  512. if (extra === BORDER_INDEX) {
  513. return val;
  514. }
  515. return val + (extra === PADDING_INDEX ? -getPBMWidth(elem, ['border'], which) : getPBMWidth(elem, ['margin'], which));
  516. }
  517. return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), which);
  518. }
  519. var cssShow = {
  520. position: 'absolute',
  521. visibility: 'hidden',
  522. display: 'block'
  523. };
  524. // fix #119 : https://github.com/kissyteam/kissy/issues/119
  525. function getWHIgnoreDisplay() {
  526. for (var _len = arguments.length, args = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
  527. args[_key2] = arguments[_key2];
  528. }
  529. var val;
  530. var elem = args[0];
  531. // in case elem is window
  532. // elem.offsetWidth === undefined
  533. if (elem.offsetWidth !== 0) {
  534. val = getWH.apply(undefined, args);
  535. } else {
  536. swap(elem, cssShow, function () {
  537. val = getWH.apply(undefined, args);
  538. });
  539. }
  540. return val;
  541. }
  542. each(['width', 'height'], function (name) {
  543. var first = name.charAt(0).toUpperCase() + name.slice(1);
  544. domUtils["outer".concat(first)] = function (el, includeMargin) {
  545. return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX);
  546. };
  547. var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];
  548. domUtils[name] = function (elem, v) {
  549. var val = v;
  550. if (val !== undefined) {
  551. if (elem) {
  552. var isBorderBox = isBorderBoxFn(elem);
  553. if (isBorderBox) {
  554. val += getPBMWidth(elem, ['padding', 'border'], which);
  555. }
  556. return css(elem, name, val);
  557. }
  558. return undefined;
  559. }
  560. return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX);
  561. };
  562. });
  563. function mix(to, from) {
  564. for (var i in from) {
  565. if (from.hasOwnProperty(i)) {
  566. to[i] = from[i];
  567. }
  568. }
  569. return to;
  570. }
  571. var utils = {
  572. getWindow: function getWindow(node) {
  573. if (node && node.document && node.setTimeout) {
  574. return node;
  575. }
  576. var doc = node.ownerDocument || node;
  577. return doc.defaultView || doc.parentWindow;
  578. },
  579. getDocument: getDocument,
  580. offset: function offset(el, value, option) {
  581. if (typeof value !== 'undefined') {
  582. setOffset(el, value, option || {});
  583. } else {
  584. return getOffset(el);
  585. }
  586. },
  587. isWindow: isWindow,
  588. each: each,
  589. css: css,
  590. clone: function clone(obj) {
  591. var i;
  592. var ret = {};
  593. for (i in obj) {
  594. if (obj.hasOwnProperty(i)) {
  595. ret[i] = obj[i];
  596. }
  597. }
  598. var overflow = obj.overflow;
  599. if (overflow) {
  600. for (i in obj) {
  601. if (obj.hasOwnProperty(i)) {
  602. ret.overflow[i] = obj.overflow[i];
  603. }
  604. }
  605. }
  606. return ret;
  607. },
  608. mix: mix,
  609. getWindowScrollLeft: function getWindowScrollLeft(w) {
  610. return getScrollLeft(w);
  611. },
  612. getWindowScrollTop: function getWindowScrollTop(w) {
  613. return getScrollTop(w);
  614. },
  615. merge: function merge() {
  616. var ret = {};
  617. for (var i = 0; i < arguments.length; i++) {
  618. utils.mix(ret, i < 0 || arguments.length <= i ? undefined : arguments[i]);
  619. }
  620. return ret;
  621. },
  622. viewportWidth: 0,
  623. viewportHeight: 0
  624. };
  625. mix(utils, domUtils);
  626. /**
  627. * 得到会导致元素显示不全的祖先元素
  628. */
  629. var getParent = utils.getParent;
  630. function getOffsetParent(element) {
  631. if (utils.isWindow(element) || element.nodeType === 9) {
  632. return null;
  633. }
  634. // ie 这个也不是完全可行
  635. /*
  636. <div style="width: 50px;height: 100px;overflow: hidden">
  637. <div style="width: 50px;height: 100px;position: relative;" id="d6">
  638. 元素 6 高 100px 宽 50px<br/>
  639. </div>
  640. </div>
  641. */
  642. // element.offsetParent does the right thing in ie7 and below. Return parent with layout!
  643. // In other browsers it only includes elements with position absolute, relative or
  644. // fixed, not elements with overflow set to auto or scroll.
  645. // if (UA.ie && ieMode < 8) {
  646. // return element.offsetParent;
  647. // }
  648. // 统一的 offsetParent 方法
  649. var doc = utils.getDocument(element);
  650. var body = doc.body;
  651. var parent;
  652. var positionStyle = utils.css(element, 'position');
  653. var skipStatic = positionStyle === 'fixed' || positionStyle === 'absolute';
  654. if (!skipStatic) {
  655. return element.nodeName.toLowerCase() === 'html' ? null : getParent(element);
  656. }
  657. for (parent = getParent(element); parent && parent !== body && parent.nodeType !== 9; parent = getParent(parent)) {
  658. positionStyle = utils.css(parent, 'position');
  659. if (positionStyle !== 'static') {
  660. return parent;
  661. }
  662. }
  663. return null;
  664. }
  665. var getParent$1 = utils.getParent;
  666. function isAncestorFixed(element) {
  667. if (utils.isWindow(element) || element.nodeType === 9) {
  668. return false;
  669. }
  670. var doc = utils.getDocument(element);
  671. var body = doc.body;
  672. var parent = null;
  673. for (parent = getParent$1(element);
  674. // 修复元素位于 document.documentElement 下导致崩溃问题
  675. parent && parent !== body && parent !== doc; parent = getParent$1(parent)) {
  676. var positionStyle = utils.css(parent, 'position');
  677. if (positionStyle === 'fixed') {
  678. return true;
  679. }
  680. }
  681. return false;
  682. }
  683. /**
  684. * 获得元素的显示部分的区域
  685. */
  686. function getVisibleRectForElement(element, alwaysByViewport) {
  687. var visibleRect = {
  688. left: 0,
  689. right: Infinity,
  690. top: 0,
  691. bottom: Infinity
  692. };
  693. var el = getOffsetParent(element);
  694. var doc = utils.getDocument(element);
  695. var win = doc.defaultView || doc.parentWindow;
  696. var body = doc.body;
  697. var documentElement = doc.documentElement;
  698. // Determine the size of the visible rect by climbing the dom accounting for
  699. // all scrollable containers.
  700. while (el) {
  701. // clientWidth is zero for inline block elements in ie.
  702. if ((navigator.userAgent.indexOf('MSIE') === -1 || el.clientWidth !== 0) &&
  703. // body may have overflow set on it, yet we still get the entire
  704. // viewport. In some browsers, el.offsetParent may be
  705. // document.documentElement, so check for that too.
  706. el !== body && el !== documentElement && utils.css(el, 'overflow') !== 'visible') {
  707. var pos = utils.offset(el);
  708. // add border
  709. pos.left += el.clientLeft;
  710. pos.top += el.clientTop;
  711. visibleRect.top = Math.max(visibleRect.top, pos.top);
  712. visibleRect.right = Math.min(visibleRect.right,
  713. // consider area without scrollBar
  714. pos.left + el.clientWidth);
  715. visibleRect.bottom = Math.min(visibleRect.bottom, pos.top + el.clientHeight);
  716. visibleRect.left = Math.max(visibleRect.left, pos.left);
  717. } else if (el === body || el === documentElement) {
  718. break;
  719. }
  720. el = getOffsetParent(el);
  721. }
  722. // Set element position to fixed
  723. // make sure absolute element itself don't affect it's visible area
  724. // https://github.com/ant-design/ant-design/issues/7601
  725. var originalPosition = null;
  726. if (!utils.isWindow(element) && element.nodeType !== 9) {
  727. originalPosition = element.style.position;
  728. var position = utils.css(element, 'position');
  729. if (position === 'absolute') {
  730. element.style.position = 'fixed';
  731. }
  732. }
  733. var scrollX = utils.getWindowScrollLeft(win);
  734. var scrollY = utils.getWindowScrollTop(win);
  735. var viewportWidth = utils.viewportWidth(win);
  736. var viewportHeight = utils.viewportHeight(win);
  737. var documentWidth = documentElement.scrollWidth;
  738. var documentHeight = documentElement.scrollHeight;
  739. // scrollXXX on html is sync with body which means overflow: hidden on body gets wrong scrollXXX.
  740. // We should cut this ourself.
  741. var bodyStyle = window.getComputedStyle(body);
  742. if (bodyStyle.overflowX === 'hidden') {
  743. documentWidth = win.innerWidth;
  744. }
  745. if (bodyStyle.overflowY === 'hidden') {
  746. documentHeight = win.innerHeight;
  747. }
  748. // Reset element position after calculate the visible area
  749. if (element.style) {
  750. element.style.position = originalPosition;
  751. }
  752. if (alwaysByViewport || isAncestorFixed(element)) {
  753. // Clip by viewport's size.
  754. visibleRect.left = Math.max(visibleRect.left, scrollX);
  755. visibleRect.top = Math.max(visibleRect.top, scrollY);
  756. visibleRect.right = Math.min(visibleRect.right, scrollX + viewportWidth);
  757. visibleRect.bottom = Math.min(visibleRect.bottom, scrollY + viewportHeight);
  758. } else {
  759. // Clip by document's size.
  760. var maxVisibleWidth = Math.max(documentWidth, scrollX + viewportWidth);
  761. visibleRect.right = Math.min(visibleRect.right, maxVisibleWidth);
  762. var maxVisibleHeight = Math.max(documentHeight, scrollY + viewportHeight);
  763. visibleRect.bottom = Math.min(visibleRect.bottom, maxVisibleHeight);
  764. }
  765. return visibleRect.top >= 0 && visibleRect.left >= 0 && visibleRect.bottom > visibleRect.top && visibleRect.right > visibleRect.left ? visibleRect : null;
  766. }
  767. function adjustForViewport(elFuturePos, elRegion, visibleRect, overflow) {
  768. var pos = utils.clone(elFuturePos);
  769. var size = {
  770. width: elRegion.width,
  771. height: elRegion.height
  772. };
  773. if (overflow.adjustX && pos.left < visibleRect.left) {
  774. pos.left = visibleRect.left;
  775. }
  776. // Left edge inside and right edge outside viewport, try to resize it.
  777. if (overflow.resizeWidth && pos.left >= visibleRect.left && pos.left + size.width > visibleRect.right) {
  778. size.width -= pos.left + size.width - visibleRect.right;
  779. }
  780. // Right edge outside viewport, try to move it.
  781. if (overflow.adjustX && pos.left + size.width > visibleRect.right) {
  782. // 保证左边界和可视区域左边界对齐
  783. pos.left = Math.max(visibleRect.right - size.width, visibleRect.left);
  784. }
  785. // Top edge outside viewport, try to move it.
  786. if (overflow.adjustY && pos.top < visibleRect.top) {
  787. pos.top = visibleRect.top;
  788. }
  789. // Top edge inside and bottom edge outside viewport, try to resize it.
  790. if (overflow.resizeHeight && pos.top >= visibleRect.top && pos.top + size.height > visibleRect.bottom) {
  791. size.height -= pos.top + size.height - visibleRect.bottom;
  792. }
  793. // Bottom edge outside viewport, try to move it.
  794. if (overflow.adjustY && pos.top + size.height > visibleRect.bottom) {
  795. // 保证上边界和可视区域上边界对齐
  796. pos.top = Math.max(visibleRect.bottom - size.height, visibleRect.top);
  797. }
  798. return utils.mix(pos, size);
  799. }
  800. function getRegion(node) {
  801. var offset;
  802. var w;
  803. var h;
  804. if (!utils.isWindow(node) && node.nodeType !== 9) {
  805. offset = utils.offset(node);
  806. w = utils.outerWidth(node);
  807. h = utils.outerHeight(node);
  808. } else {
  809. var win = utils.getWindow(node);
  810. offset = {
  811. left: utils.getWindowScrollLeft(win),
  812. top: utils.getWindowScrollTop(win)
  813. };
  814. w = utils.viewportWidth(win);
  815. h = utils.viewportHeight(win);
  816. }
  817. offset.width = w;
  818. offset.height = h;
  819. return offset;
  820. }
  821. /**
  822. * 获取 node 上的 align 对齐点 相对于页面的坐标
  823. */
  824. function getAlignOffset(region, align) {
  825. var V = align.charAt(0);
  826. var H = align.charAt(1);
  827. var w = region.width;
  828. var h = region.height;
  829. var x = region.left;
  830. var y = region.top;
  831. if (V === 'c') {
  832. y += h / 2;
  833. } else if (V === 'b') {
  834. y += h;
  835. }
  836. if (H === 'c') {
  837. x += w / 2;
  838. } else if (H === 'r') {
  839. x += w;
  840. }
  841. return {
  842. left: x,
  843. top: y
  844. };
  845. }
  846. function getElFuturePos(elRegion, refNodeRegion, points, offset, targetOffset) {
  847. var p1 = getAlignOffset(refNodeRegion, points[1]);
  848. var p2 = getAlignOffset(elRegion, points[0]);
  849. var diff = [p2.left - p1.left, p2.top - p1.top];
  850. return {
  851. left: Math.round(elRegion.left - diff[0] + offset[0] - targetOffset[0]),
  852. top: Math.round(elRegion.top - diff[1] + offset[1] - targetOffset[1])
  853. };
  854. }
  855. /**
  856. * align dom node flexibly
  857. * @author yiminghe@gmail.com
  858. */
  859. // http://yiminghe.iteye.com/blog/1124720
  860. function isFailX(elFuturePos, elRegion, visibleRect) {
  861. return elFuturePos.left < visibleRect.left || elFuturePos.left + elRegion.width > visibleRect.right;
  862. }
  863. function isFailY(elFuturePos, elRegion, visibleRect) {
  864. return elFuturePos.top < visibleRect.top || elFuturePos.top + elRegion.height > visibleRect.bottom;
  865. }
  866. function isCompleteFailX(elFuturePos, elRegion, visibleRect) {
  867. return elFuturePos.left > visibleRect.right || elFuturePos.left + elRegion.width < visibleRect.left;
  868. }
  869. function isCompleteFailY(elFuturePos, elRegion, visibleRect) {
  870. return elFuturePos.top > visibleRect.bottom || elFuturePos.top + elRegion.height < visibleRect.top;
  871. }
  872. function flip(points, reg, map) {
  873. var ret = [];
  874. utils.each(points, function (p) {
  875. ret.push(p.replace(reg, function (m) {
  876. return map[m];
  877. }));
  878. });
  879. return ret;
  880. }
  881. function flipOffset(offset, index) {
  882. offset[index] = -offset[index];
  883. return offset;
  884. }
  885. function convertOffset(str, offsetLen) {
  886. var n;
  887. if (/%$/.test(str)) {
  888. n = parseInt(str.substring(0, str.length - 1), 10) / 100 * offsetLen;
  889. } else {
  890. n = parseInt(str, 10);
  891. }
  892. return n || 0;
  893. }
  894. function normalizeOffset(offset, el) {
  895. offset[0] = convertOffset(offset[0], el.width);
  896. offset[1] = convertOffset(offset[1], el.height);
  897. }
  898. /**
  899. * @param el
  900. * @param tgtRegion 参照节点所占的区域: { left, top, width, height }
  901. * @param align
  902. */
  903. function doAlign(el, tgtRegion, align, isTgtRegionVisible) {
  904. var points = align.points;
  905. var offset = align.offset || [0, 0];
  906. var targetOffset = align.targetOffset || [0, 0];
  907. var overflow = align.overflow;
  908. var source = align.source || el;
  909. offset = [].concat(offset);
  910. targetOffset = [].concat(targetOffset);
  911. overflow = overflow || {};
  912. var newOverflowCfg = {};
  913. var fail = 0;
  914. var alwaysByViewport = !!(overflow && overflow.alwaysByViewport);
  915. // 当前节点可以被放置的显示区域
  916. var visibleRect = getVisibleRectForElement(source, alwaysByViewport);
  917. // 当前节点所占的区域, left/top/width/height
  918. var elRegion = getRegion(source);
  919. // 将 offset 转换成数值,支持百分比
  920. normalizeOffset(offset, elRegion);
  921. normalizeOffset(targetOffset, tgtRegion);
  922. // 当前节点将要被放置的位置
  923. var elFuturePos = getElFuturePos(elRegion, tgtRegion, points, offset, targetOffset);
  924. // 当前节点将要所处的区域
  925. var newElRegion = utils.merge(elRegion, elFuturePos);
  926. // 如果可视区域不能完全放置当前节点时允许调整
  927. if (visibleRect && (overflow.adjustX || overflow.adjustY) && isTgtRegionVisible) {
  928. if (overflow.adjustX) {
  929. // 如果横向不能放下
  930. if (isFailX(elFuturePos, elRegion, visibleRect)) {
  931. // 对齐位置反下
  932. var newPoints = flip(points, /[lr]/gi, {
  933. l: 'r',
  934. r: 'l'
  935. });
  936. // 偏移量也反下
  937. var newOffset = flipOffset(offset, 0);
  938. var newTargetOffset = flipOffset(targetOffset, 0);
  939. var newElFuturePos = getElFuturePos(elRegion, tgtRegion, newPoints, newOffset, newTargetOffset);
  940. if (!isCompleteFailX(newElFuturePos, elRegion, visibleRect)) {
  941. fail = 1;
  942. points = newPoints;
  943. offset = newOffset;
  944. targetOffset = newTargetOffset;
  945. }
  946. }
  947. }
  948. if (overflow.adjustY) {
  949. // 如果纵向不能放下
  950. if (isFailY(elFuturePos, elRegion, visibleRect)) {
  951. // 对齐位置反下
  952. var _newPoints = flip(points, /[tb]/gi, {
  953. t: 'b',
  954. b: 't'
  955. });
  956. // 偏移量也反下
  957. var _newOffset = flipOffset(offset, 1);
  958. var _newTargetOffset = flipOffset(targetOffset, 1);
  959. var _newElFuturePos = getElFuturePos(elRegion, tgtRegion, _newPoints, _newOffset, _newTargetOffset);
  960. if (!isCompleteFailY(_newElFuturePos, elRegion, visibleRect)) {
  961. fail = 1;
  962. points = _newPoints;
  963. offset = _newOffset;
  964. targetOffset = _newTargetOffset;
  965. }
  966. }
  967. }
  968. // 如果失败,重新计算当前节点将要被放置的位置
  969. if (fail) {
  970. elFuturePos = getElFuturePos(elRegion, tgtRegion, points, offset, targetOffset);
  971. utils.mix(newElRegion, elFuturePos);
  972. }
  973. var isStillFailX = isFailX(elFuturePos, elRegion, visibleRect);
  974. var isStillFailY = isFailY(elFuturePos, elRegion, visibleRect);
  975. // 检查反下后的位置是否可以放下了,如果仍然放不下:
  976. // 1. 复原修改过的定位参数
  977. if (isStillFailX || isStillFailY) {
  978. var _newPoints2 = points;
  979. // 重置对应部分的翻转逻辑
  980. if (isStillFailX) {
  981. _newPoints2 = flip(points, /[lr]/gi, {
  982. l: 'r',
  983. r: 'l'
  984. });
  985. }
  986. if (isStillFailY) {
  987. _newPoints2 = flip(points, /[tb]/gi, {
  988. t: 'b',
  989. b: 't'
  990. });
  991. }
  992. points = _newPoints2;
  993. offset = align.offset || [0, 0];
  994. targetOffset = align.targetOffset || [0, 0];
  995. }
  996. // 2. 只有指定了可以调整当前方向才调整
  997. newOverflowCfg.adjustX = overflow.adjustX && isStillFailX;
  998. newOverflowCfg.adjustY = overflow.adjustY && isStillFailY;
  999. // 确实要调整,甚至可能会调整高度宽度
  1000. if (newOverflowCfg.adjustX || newOverflowCfg.adjustY) {
  1001. newElRegion = adjustForViewport(elFuturePos, elRegion, visibleRect, newOverflowCfg);
  1002. }
  1003. }
  1004. // need judge to in case set fixed with in css on height auto element
  1005. if (newElRegion.width !== elRegion.width) {
  1006. utils.css(source, 'width', utils.width(source) + newElRegion.width - elRegion.width);
  1007. }
  1008. if (newElRegion.height !== elRegion.height) {
  1009. utils.css(source, 'height', utils.height(source) + newElRegion.height - elRegion.height);
  1010. }
  1011. // https://github.com/kissyteam/kissy/issues/190
  1012. // 相对于屏幕位置没变,而 left/top 变了
  1013. // 例如 <div 'relative'><el absolute></div>
  1014. utils.offset(source, {
  1015. left: newElRegion.left,
  1016. top: newElRegion.top
  1017. }, {
  1018. useCssRight: align.useCssRight,
  1019. useCssBottom: align.useCssBottom,
  1020. useCssTransform: align.useCssTransform,
  1021. ignoreShake: align.ignoreShake
  1022. });
  1023. return {
  1024. points: points,
  1025. offset: offset,
  1026. targetOffset: targetOffset,
  1027. overflow: newOverflowCfg
  1028. };
  1029. }
  1030. /**
  1031. * 2012-04-26 yiminghe@gmail.com
  1032. * - 优化智能对齐算法
  1033. * - 慎用 resizeXX
  1034. *
  1035. * 2011-07-13 yiminghe@gmail.com note:
  1036. * - 增加智能对齐,以及大小调整选项
  1037. **/
  1038. function isOutOfVisibleRect(target, alwaysByViewport) {
  1039. var visibleRect = getVisibleRectForElement(target, alwaysByViewport);
  1040. var targetRegion = getRegion(target);
  1041. return !visibleRect || targetRegion.left + targetRegion.width <= visibleRect.left || targetRegion.top + targetRegion.height <= visibleRect.top || targetRegion.left >= visibleRect.right || targetRegion.top >= visibleRect.bottom;
  1042. }
  1043. function alignElement(el, refNode, align) {
  1044. var target = align.target || refNode;
  1045. var refNodeRegion = getRegion(target);
  1046. var isTargetNotOutOfVisible = !isOutOfVisibleRect(target, align.overflow && align.overflow.alwaysByViewport);
  1047. return doAlign(el, refNodeRegion, align, isTargetNotOutOfVisible);
  1048. }
  1049. alignElement.__getOffsetParent = getOffsetParent;
  1050. alignElement.__getVisibleRectForElement = getVisibleRectForElement;
  1051. function ownKeys(object, enumerableOnly) {
  1052. var keys = Object.keys(object);
  1053. if (Object.getOwnPropertySymbols) {
  1054. var symbols = Object.getOwnPropertySymbols(object);
  1055. enumerableOnly && (symbols = symbols.filter(function (sym) {
  1056. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  1057. })), keys.push.apply(keys, symbols);
  1058. }
  1059. return keys;
  1060. }
  1061. function _objectSpread(target) {
  1062. for (var i = 1; i < arguments.length; i++) {
  1063. var source = null != arguments[i] ? arguments[i] : {};
  1064. i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
  1065. _defineProperty(target, key, source[key]);
  1066. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
  1067. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  1068. });
  1069. }
  1070. return target;
  1071. }
  1072. function _defineProperty(obj, key, value) {
  1073. if (key in obj) {
  1074. Object.defineProperty(obj, key, {
  1075. value: value,
  1076. enumerable: true,
  1077. configurable: true,
  1078. writable: true
  1079. });
  1080. } else {
  1081. obj[key] = value;
  1082. }
  1083. return obj;
  1084. }
  1085. /**
  1086. * `tgtPoint`: { pageX, pageY } or { clientX, clientY }.
  1087. * If client position provided, will internal convert to page position.
  1088. */
  1089. function alignPoint(el, tgtPoint, align) {
  1090. var pageX;
  1091. var pageY;
  1092. var doc = utils.getDocument(el);
  1093. var win = doc.defaultView || doc.parentWindow;
  1094. var scrollX = utils.getWindowScrollLeft(win);
  1095. var scrollY = utils.getWindowScrollTop(win);
  1096. var viewportWidth = utils.viewportWidth(win);
  1097. var viewportHeight = utils.viewportHeight(win);
  1098. if ('pageX' in tgtPoint) {
  1099. pageX = tgtPoint.pageX;
  1100. } else {
  1101. pageX = scrollX + tgtPoint.clientX;
  1102. }
  1103. if ('pageY' in tgtPoint) {
  1104. pageY = tgtPoint.pageY;
  1105. } else {
  1106. pageY = scrollY + tgtPoint.clientY;
  1107. }
  1108. var tgtRegion = {
  1109. left: pageX,
  1110. top: pageY,
  1111. width: 0,
  1112. height: 0
  1113. };
  1114. var pointInView = pageX >= 0 && pageX <= scrollX + viewportWidth && pageY >= 0 && pageY <= scrollY + viewportHeight;
  1115. // Provide default target point
  1116. var points = [align.points[0], 'cc'];
  1117. return doAlign(el, tgtRegion, _objectSpread(_objectSpread({}, align), {}, {
  1118. points: points
  1119. }), pointInView);
  1120. }
  1121. exports.alignElement = alignElement;
  1122. exports.alignPoint = alignPoint;
  1123. exports.default = alignElement;
  1124. //# sourceMappingURL=index.js.map