canvas-datagrid 0.3.22 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/dom.js CHANGED
@@ -123,14 +123,27 @@ export default function (self) {
123
123
  self.input.style.width = self.width - borderWidth - 1 + 'px';
124
124
  return;
125
125
  }
126
+ let groupAreaOffsetY = self.getColumnGroupAreaHeight();
127
+ let groupAreaOffsetX = self.getRowGroupAreaWidth();
128
+ if (self.parentNode) {
129
+ const { columnGroupsAreaHeight, rowGroupsAreaWidth } = self.parentNode;
130
+ if (columnGroupsAreaHeight) groupAreaOffsetY += columnGroupsAreaHeight;
131
+ if (rowGroupsAreaWidth) groupAreaOffsetX += rowGroupsAreaWidth;
132
+ }
126
133
  self.input.style.left =
127
- pos.left + cell.x + self.canvasOffsetLeft - s.left + 'px';
134
+ pos.left +
135
+ cell.x +
136
+ self.canvasOffsetLeft -
137
+ s.left +
138
+ groupAreaOffsetX +
139
+ 'px';
128
140
  self.input.style.top =
129
141
  pos.top +
130
142
  cell.y -
131
143
  self.style.cellBorderWidth +
132
144
  self.canvasOffsetTop -
133
145
  s.top +
146
+ groupAreaOffsetY +
134
147
  'px';
135
148
  self.input.style.height = cell.height - borderWidth + 'px';
136
149
  self.input.style.width = cell.width - self.style.cellPaddingLeft + 'px';
@@ -143,11 +156,16 @@ export default function (self) {
143
156
  s = e,
144
157
  h,
145
158
  w;
159
+ let calculatedTree = false;
146
160
  while (e.offsetParent && e.nodeName !== 'CANVAS-DATAGRID') {
147
- x += e.offsetLeft;
148
- y += e.offsetTop;
149
- h = e.offsetHeight;
150
- w = e.offsetWidth;
161
+ const isTree = e.nodeType === 'canvas-datagrid-tree';
162
+ if (!isTree || !calculatedTree) {
163
+ x += e.offsetLeft;
164
+ y += e.offsetTop;
165
+ h = e.offsetHeight;
166
+ w = e.offsetWidth;
167
+ }
168
+ if (isTree) calculatedTree = true;
151
169
  e = e.offsetParent;
152
170
  }
153
171
  if (ignoreScrollOffset) {
@@ -166,6 +184,10 @@ export default function (self) {
166
184
  if (self.isChildGrid) {
167
185
  pos.x -= self.canvasOffsetLeft;
168
186
  pos.y -= self.canvasOffsetTop;
187
+ if (self.parentNode.rowGroupsAreaWidth)
188
+ pos.x -= self.parentNode.rowGroupsAreaWidth;
189
+ if (self.parentNode.columnGroupsAreaHeight)
190
+ pos.y -= self.parentNode.columnGroupsAreaHeight;
169
191
  }
170
192
  return {
171
193
  x: pos.x,