af2caa6e7078a27e30ae971ad3f42700d00bf6b7cfaabf7976555c2fb7940fb872006b0338547c3d9cc9ce9d48a6aed31b0f77ca8b047b102816c86983694c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5. import { outerHeight, outerWidth, setOverlayPosition, resetCssTransform } from './../../../../helpers/dom/element';
  6. import Overlay from './_base';
  7. /**
  8. * @class TopLeftCornerOverlay
  9. */
  10. var TopLeftCornerOverlay = function (_Overlay) {
  11. _inherits(TopLeftCornerOverlay, _Overlay);
  12. /**
  13. * @param {Walkontable} wotInstance
  14. */
  15. function TopLeftCornerOverlay(wotInstance) {
  16. _classCallCheck(this, TopLeftCornerOverlay);
  17. var _this = _possibleConstructorReturn(this, (TopLeftCornerOverlay.__proto__ || Object.getPrototypeOf(TopLeftCornerOverlay)).call(this, wotInstance));
  18. _this.clone = _this.makeClone(Overlay.CLONE_TOP_LEFT_CORNER);
  19. return _this;
  20. }
  21. /**
  22. * Checks if overlay should be fully rendered
  23. *
  24. * @returns {Boolean}
  25. */
  26. _createClass(TopLeftCornerOverlay, [{
  27. key: 'shouldBeRendered',
  28. value: function shouldBeRendered() {
  29. return !!((this.wot.getSetting('fixedRowsTop') || this.wot.getSetting('columnHeaders').length) && (this.wot.getSetting('fixedColumnsLeft') || this.wot.getSetting('rowHeaders').length));
  30. }
  31. /**
  32. * Updates the corner overlay position
  33. */
  34. }, {
  35. key: 'resetFixedPosition',
  36. value: function resetFixedPosition() {
  37. this.updateTrimmingContainer();
  38. if (!this.wot.wtTable.holder.parentNode) {
  39. // removed from DOM
  40. return;
  41. }
  42. var overlayRoot = this.clone.wtTable.holder.parentNode;
  43. var tableHeight = outerHeight(this.clone.wtTable.TABLE);
  44. var tableWidth = outerWidth(this.clone.wtTable.TABLE);
  45. var preventOverflow = this.wot.getSetting('preventOverflow');
  46. if (this.trimmingContainer === window) {
  47. var box = this.wot.wtTable.hider.getBoundingClientRect();
  48. var top = Math.ceil(box.top);
  49. var left = Math.ceil(box.left);
  50. var bottom = Math.ceil(box.bottom);
  51. var right = Math.ceil(box.right);
  52. var finalLeft = '0';
  53. var finalTop = '0';
  54. if (!preventOverflow || preventOverflow === 'vertical') {
  55. if (left < 0 && right - overlayRoot.offsetWidth > 0) {
  56. finalLeft = -left + 'px';
  57. }
  58. }
  59. if (!preventOverflow || preventOverflow === 'horizontal') {
  60. if (top < 0 && bottom - overlayRoot.offsetHeight > 0) {
  61. finalTop = -top + 'px';
  62. }
  63. }
  64. setOverlayPosition(overlayRoot, finalLeft, finalTop);
  65. } else {
  66. resetCssTransform(overlayRoot);
  67. }
  68. overlayRoot.style.height = (tableHeight === 0 ? tableHeight : tableHeight + 4) + 'px';
  69. overlayRoot.style.width = (tableWidth === 0 ? tableWidth : tableWidth + 4) + 'px';
  70. }
  71. }]);
  72. return TopLeftCornerOverlay;
  73. }(Overlay);
  74. Overlay.registerOverlay(Overlay.CLONE_TOP_LEFT_CORNER, TopLeftCornerOverlay);
  75. export default TopLeftCornerOverlay;