index.js 37 KB

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