canvas-datagrid 0.26.0 → 0.27.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/CHANGELOG.md +25 -0
- package/dist/canvas-datagrid.debug.js +175 -49
- package/dist/canvas-datagrid.debug.map +1 -1
- package/dist/canvas-datagrid.js +1 -1
- package/dist/canvas-datagrid.module.js +1 -1
- package/dist/canvas-datagrid.module.js.map +1 -1
- package/dist/types.d.ts +5 -5
- package/lib/docs.js +3 -3
- package/lib/dom.js +86 -4
- package/lib/draw.js +20 -4
- package/lib/events/index.js +70 -47
- package/lib/intf.js +6 -1
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -149,7 +149,7 @@
|
|
|
149
149
|
* @param [args.touchZoomMin = 0.5] - The minimum zoom scale.
|
|
150
150
|
* @param [args.touchZoomMax = 1.75] - The maximum zoom scale.
|
|
151
151
|
* @param [args.maxPixelRatio = 1.5] - The maximum pixel ratio for high DPI displays. High DPI displays can cause sluggish performance, this caps resolution the grid is rendered at. Standard resolution (e.g.: 1920x1080) have a pixel ratio of 1:1 while higher resolution displays can be higher (e.g.: Retina display 2:1). Higher numbers are sharper (higher resolution) up to the max of your display (usually 2), lower numbers are lower resolution, down to 1. It might be fun to set a value lower than 1, I've never done it.
|
|
152
|
-
* @param [args.maxCanvasSize = 16384] - Largest width or height, in CSS pixels, an auto-sized grid (`style.width`/`style.height`
|
|
152
|
+
* @param [args.maxCanvasSize = 16384] - Largest width or height, in CSS pixels, an auto-sized grid (`style.width`/`style.height` left at `auto`) may grow to. Browsers cannot paint larger canvases. Past this size the grid stops growing and shows a scroll bar for the rest of the data.
|
|
153
153
|
* @param [args.fillCellCallback] - The callback function that is called when a cell is filled.
|
|
154
154
|
* @param [args.style = {}] - Sets selected values in style.
|
|
155
155
|
* @param [args.filters = {}] - Sets selected values in filters. See {@link canvasDatagrid.filters}.
|
|
@@ -1343,7 +1343,7 @@ declare namespace canvasDatagrid {
|
|
|
1343
1343
|
* @property [columnHeaderOrderByArrowWidth = 13] - Style of columnHeaderOrderByArrowWidth.
|
|
1344
1344
|
* @property [rowHeaderCellWidth = 57] - Style of rowHeaderCellWidth.
|
|
1345
1345
|
* @property [minColumnWidth = 45] - Style of minColumnWidth.
|
|
1346
|
-
* @property [height = auto] -
|
|
1346
|
+
* @property [height = auto] - Height of the grid as a CSS value (`300px`, `100%`). With the default `auto` the grid fills its parent element when the parent has a height of its own; otherwise it grows to fit its rows, but never past the viewport height, and scrolls for the rest.
|
|
1347
1347
|
* @property [minHeight = 24] - Style of minHeight.
|
|
1348
1348
|
* @property [minRowHeight = 24] - Style of minRowHeight.
|
|
1349
1349
|
* @property [name = default] - Style of name.
|
|
@@ -1413,7 +1413,7 @@ declare namespace canvasDatagrid {
|
|
|
1413
1413
|
* @property [frozenMarkerWidth = 1] - Style of frozenMarkerWidth.
|
|
1414
1414
|
* @property [overflowY = auto] - When set to hidden, vertical scroll bar will be hidden. When set to auto vertical scroll bar will appear when data overflows the height. When set to scroll the vertical scrollbar will always be visible.
|
|
1415
1415
|
* @property [overflowX = auto] - When set to hidden, horizontal scroll bar will be hidden. When set to auto horizontal scroll bar will appear when data overflows the width. When set to scroll the horizontal scrollbar will always be visible.
|
|
1416
|
-
* @property [width = auto] -
|
|
1416
|
+
* @property [width = auto] - Width of the grid as a CSS value (`800px`, `100%`). With the default `auto` the grid fills its parent element when the parent has a width of its own; otherwise it grows to fit its columns, but never past the viewport width, and scrolls for the rest.
|
|
1417
1417
|
*
|
|
1418
1418
|
* ['', 'normal'],
|
|
1419
1419
|
*/
|
|
@@ -1979,7 +1979,7 @@ declare namespace canvasDatagrid {
|
|
|
1979
1979
|
*/
|
|
1980
1980
|
minColumnWidth?: number;
|
|
1981
1981
|
/**
|
|
1982
|
-
*
|
|
1982
|
+
* Height of the grid as a CSS value (`300px`, `100%`). With the default `auto` the grid fills its parent element when the parent has a height of its own; otherwise it grows to fit its rows, but never past the viewport height, and scrolls for the rest.
|
|
1983
1983
|
*/
|
|
1984
1984
|
height?: number | string;
|
|
1985
1985
|
/**
|
|
@@ -2259,7 +2259,7 @@ declare namespace canvasDatagrid {
|
|
|
2259
2259
|
*/
|
|
2260
2260
|
overflowX?: string;
|
|
2261
2261
|
/**
|
|
2262
|
-
*
|
|
2262
|
+
* Width of the grid as a CSS value (`800px`, `100%`). With the default `auto` the grid fills its parent element when the parent has a width of its own; otherwise it grows to fit its columns, but never past the viewport width, and scrolls for the rest.
|
|
2263
2263
|
|
|
2264
2264
|
['', 'normal'],
|
|
2265
2265
|
*/
|
package/lib/docs.js
CHANGED
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
* @param {number} [args.touchZoomMin=0.5] - The minimum zoom scale.
|
|
113
113
|
* @param {number} [args.touchZoomMax=1.75] - The maximum zoom scale.
|
|
114
114
|
* @param {number} [args.maxPixelRatio=1.5] - The maximum pixel ratio for high DPI displays. High DPI displays can cause sluggish performance, this caps resolution the grid is rendered at. Standard resolution (e.g.: 1920x1080) have a pixel ratio of 1:1 while higher resolution displays can be higher (e.g.: Retina display 2:1). Higher numbers are sharper (higher resolution) up to the max of your display (usually 2), lower numbers are lower resolution, down to 1. It might be fun to set a value lower than 1, I've never done it.
|
|
115
|
-
* @param {number} [args.maxCanvasSize=16384] - Largest width or height, in CSS pixels, an auto-sized grid (`style.width`/`style.height`
|
|
115
|
+
* @param {number} [args.maxCanvasSize=16384] - Largest width or height, in CSS pixels, an auto-sized grid (`style.width`/`style.height` left at `auto`) may grow to. Browsers cannot paint larger canvases. Past this size the grid stops growing and shows a scroll bar for the rest of the data.
|
|
116
116
|
* @param {object} [args.fillCellCallback] - The callback function that is called when a cell is filled.
|
|
117
117
|
* @param {canvasDatagrid.style} [args.style={}] - Sets selected values in style.
|
|
118
118
|
* @param {canvasDatagrid.filter} [args.filters={}] - Sets selected values in filters. See {@link canvasDatagrid.filters}.
|
|
@@ -434,7 +434,7 @@
|
|
|
434
434
|
* @property {number} [columnHeaderOrderByArrowWidth=13] - Style of columnHeaderOrderByArrowWidth.
|
|
435
435
|
* @property {number} [rowHeaderCellWidth=57] - Style of rowHeaderCellWidth.
|
|
436
436
|
* @property {number} [minColumnWidth=45] - Style of minColumnWidth.
|
|
437
|
-
* @property {(number|string)} [height=auto] -
|
|
437
|
+
* @property {(number|string)} [height=auto] - Height of the grid as a CSS value (`300px`, `100%`). With the default `auto` the grid fills its parent element when the parent has a height of its own; otherwise it grows to fit its rows, but never past the viewport height, and scrolls for the rest.
|
|
438
438
|
* @property {number} [minHeight=24] - Style of minHeight.
|
|
439
439
|
* @property {number} [minRowHeight=24] - Style of minRowHeight.
|
|
440
440
|
* @property {string} [name=default] - Style of name.
|
|
@@ -504,7 +504,7 @@
|
|
|
504
504
|
* @property {number} [frozenMarkerWidth=1] - Style of frozenMarkerWidth.
|
|
505
505
|
* @property {string} [overflowY=auto] - When set to hidden, vertical scroll bar will be hidden. When set to auto vertical scroll bar will appear when data overflows the height. When set to scroll the vertical scrollbar will always be visible.
|
|
506
506
|
* @property {string} [overflowX=auto] - When set to hidden, horizontal scroll bar will be hidden. When set to auto horizontal scroll bar will appear when data overflows the width. When set to scroll the horizontal scrollbar will always be visible.
|
|
507
|
-
* @property {(number|string)} [width=auto] -
|
|
507
|
+
* @property {(number|string)} [width=auto] - Width of the grid as a CSS value (`800px`, `100%`). With the default `auto` the grid fills its parent element when the parent has a width of its own; otherwise it grows to fit its columns, but never past the viewport width, and scrolls for the rest.
|
|
508
508
|
|
|
509
509
|
['', 'normal'],
|
|
510
510
|
*/
|
package/lib/dom.js
CHANGED
|
@@ -196,9 +196,91 @@ export default function (self) {
|
|
|
196
196
|
};
|
|
197
197
|
};
|
|
198
198
|
/**
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
199
|
+
* The element the grid sits in: the parent of the `canvas-datagrid` host
|
|
200
|
+
* element, or the host of the shadow tree the grid was placed in.
|
|
201
|
+
* @returns {HTMLElement|undefined}
|
|
202
|
+
*/
|
|
203
|
+
self.getContainerElement = function () {
|
|
204
|
+
var host = self.intf && self.intf.nodeType === 1 ? self.intf : self.canvas,
|
|
205
|
+
container = host && host.parentNode;
|
|
206
|
+
if (container && container.nodeType === 11 && container.host) {
|
|
207
|
+
container = container.host;
|
|
208
|
+
}
|
|
209
|
+
return container && container.nodeType === 1 ? container : undefined;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Measures the room the container offers the grid in each dimension.
|
|
213
|
+
* A dimension is `undefined` when the container has no size of its own
|
|
214
|
+
* there, that is when it grows with the grid (an auto height block, a
|
|
215
|
+
* shrink-to-fit width); the caller then falls back to the content size.
|
|
216
|
+
*
|
|
217
|
+
* The probe makes the canvas one pixel larger than the container's client
|
|
218
|
+
* size and checks whether the container followed. When it did not, the
|
|
219
|
+
* overflow that the probe produced tells how much of the container is
|
|
220
|
+
* taken by padding and siblings. Everything is restored synchronously, so
|
|
221
|
+
* nothing is painted and no ResizeObserver notification results.
|
|
222
|
+
* @returns {{width: (number|undefined), height: (number|undefined)}}
|
|
223
|
+
*/
|
|
224
|
+
self.measureContainerSpace = function () {
|
|
225
|
+
var space = {},
|
|
226
|
+
canvas = self.canvas,
|
|
227
|
+
container = self.getContainerElement(),
|
|
228
|
+
cache = self.containerSpaceCache,
|
|
229
|
+
canvasStyle,
|
|
230
|
+
saved;
|
|
231
|
+
if (!container || !canvas) {
|
|
232
|
+
return space;
|
|
233
|
+
}
|
|
234
|
+
if (
|
|
235
|
+
cache &&
|
|
236
|
+
cache.container === container &&
|
|
237
|
+
cache.clientWidth === container.clientWidth &&
|
|
238
|
+
cache.clientHeight === container.clientHeight
|
|
239
|
+
) {
|
|
240
|
+
return cache.space;
|
|
241
|
+
}
|
|
242
|
+
canvasStyle = canvas.style;
|
|
243
|
+
saved = { width: canvasStyle.width, height: canvasStyle.height };
|
|
244
|
+
['height', 'width'].forEach(function (dim) {
|
|
245
|
+
var client = dim === 'height' ? 'clientHeight' : 'clientWidth',
|
|
246
|
+
scroll = dim === 'height' ? 'scrollHeight' : 'scrollWidth',
|
|
247
|
+
before = container[client],
|
|
248
|
+
probe = before + 1,
|
|
249
|
+
after;
|
|
250
|
+
canvasStyle[dim] = probe + 'px';
|
|
251
|
+
after = container[client];
|
|
252
|
+
if (before === 0 || after > before) {
|
|
253
|
+
// nothing to measure (hidden or inline) or the container grew with
|
|
254
|
+
// the grid: it has no size of its own in this dimension
|
|
255
|
+
space[dim] = undefined;
|
|
256
|
+
} else {
|
|
257
|
+
// the container kept its size and the grid overflows it by at least
|
|
258
|
+
// one pixel; the overflow beyond that pixel is padding and siblings
|
|
259
|
+
space[dim] = Math.max(
|
|
260
|
+
0,
|
|
261
|
+
Math.min(after, 2 * after + 1 - container[scroll]),
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
canvasStyle[dim] = saved[dim];
|
|
265
|
+
});
|
|
266
|
+
// resize() may run several times in one frame (drags, style changes);
|
|
267
|
+
// the probe forces layout, so reuse the result while the container
|
|
268
|
+
// keeps its size
|
|
269
|
+
self.containerSpaceCache = {
|
|
270
|
+
container: container,
|
|
271
|
+
clientWidth: container.clientWidth,
|
|
272
|
+
clientHeight: container.clientHeight,
|
|
273
|
+
space: space,
|
|
274
|
+
};
|
|
275
|
+
requestAnimationFrame(function () {
|
|
276
|
+
self.containerSpaceCache = undefined;
|
|
277
|
+
});
|
|
278
|
+
return space;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* Watches the host element and its container for size changes so a grid
|
|
282
|
+
* sized with auto/percentage dimensions follows layout changes (flex,
|
|
283
|
+
* splitters, tab switches) without an explicit `resize()` call (#289, #239).
|
|
202
284
|
* Falls back to the `window` resize listener when ResizeObserver is missing.
|
|
203
285
|
*/
|
|
204
286
|
self.initResizeObserver = function () {
|
|
@@ -240,7 +322,7 @@ export default function (self) {
|
|
|
240
322
|
self.resizeObserver.disconnect();
|
|
241
323
|
self.observedSizes = new Map();
|
|
242
324
|
var host = self.intf && self.intf.nodeType === 1 ? self.intf : self.canvas;
|
|
243
|
-
[host,
|
|
325
|
+
[host, self.getContainerElement()].forEach(function (target) {
|
|
244
326
|
if (target && target.nodeType === 1) {
|
|
245
327
|
self.resizeObserver.observe(target);
|
|
246
328
|
}
|
package/lib/draw.js
CHANGED
|
@@ -1913,15 +1913,31 @@ export default function (self) {
|
|
|
1913
1913
|
columnGroupsAreaHeight || 0;
|
|
1914
1914
|
treeGrid.parentNode.rowGroupsAreaWidth += rowGroupsAreaWidth || 0;
|
|
1915
1915
|
}
|
|
1916
|
+
// Hit-test entry for the child grid's area. Like every other visible
|
|
1917
|
+
// cell it is in this grid's own coordinates (the child's offsetTop and
|
|
1918
|
+
// offsetLeft are canvas coordinates) and carries the real tree size:
|
|
1919
|
+
// `treeGrid.height`/`width` are undefined on child grids, which made
|
|
1920
|
+
// this entry unmatchable, so a pointer over a tree grid still counted
|
|
1921
|
+
// as hovering the parent and the parent scrolled along with the tree.
|
|
1916
1922
|
self.visibleCells.unshift({
|
|
1917
1923
|
rowIndex: rowOrderIndex,
|
|
1918
1924
|
columnIndex: 0,
|
|
1919
|
-
y:
|
|
1920
|
-
x:
|
|
1921
|
-
height:
|
|
1922
|
-
width: treeGrid.
|
|
1925
|
+
y: y + rowSansTreeHeight,
|
|
1926
|
+
x: rowHeaderCellWidth - 1,
|
|
1927
|
+
height: treeHeight,
|
|
1928
|
+
width: treeGrid.parentNode.offsetWidth,
|
|
1923
1929
|
style: 'tree-grid',
|
|
1924
1930
|
type: treeGrid.parentNode.nodeType,
|
|
1931
|
+
data: rowData,
|
|
1932
|
+
header: {},
|
|
1933
|
+
isGrid: false,
|
|
1934
|
+
isNormal: false,
|
|
1935
|
+
isHeader: false,
|
|
1936
|
+
isCorner: false,
|
|
1937
|
+
isRowHeader: false,
|
|
1938
|
+
isColumnHeader: false,
|
|
1939
|
+
selected: false,
|
|
1940
|
+
hovered: false,
|
|
1925
1941
|
});
|
|
1926
1942
|
treeGrid.draw();
|
|
1927
1943
|
} else if (treeGrid) {
|
package/lib/events/index.js
CHANGED
|
@@ -169,18 +169,24 @@ export default function (self) {
|
|
|
169
169
|
rowHeaderCellWidth = self.getRowHeaderCellWidth(),
|
|
170
170
|
topGroupAreaHeight = self.getColumnGroupAreaHeight(),
|
|
171
171
|
leftGroupAreaWidth = self.getRowGroupAreaWidth(),
|
|
172
|
-
ch = self.style.cellHeight
|
|
173
|
-
|
|
172
|
+
ch = self.style.cellHeight,
|
|
173
|
+
containerSpace = self.isChildGrid ? {} : self.measureContainerSpace();
|
|
174
|
+
function isAutoSize(value) {
|
|
175
|
+
return value === undefined || value === 'auto' || value === '';
|
|
176
|
+
}
|
|
174
177
|
function checkScrollBoxVisibility() {
|
|
175
|
-
|
|
178
|
+
// an auto-sized grid shows a scroll bar only when it could not grow to
|
|
179
|
+
// its content (container, viewport or canvas limit); a child grid is
|
|
180
|
+
// always bounded by the tree row or cell that holds it
|
|
181
|
+
var constrained = self.autoSizeConstrained || {};
|
|
176
182
|
self.scrollBox.horizontalBarVisible =
|
|
177
|
-
((self.style.width
|
|
183
|
+
((!isAutoSize(self.style.width) || constrained.width) &&
|
|
178
184
|
dataWidth > self.scrollBox.width &&
|
|
179
185
|
self.style.overflowX !== 'hidden') ||
|
|
180
186
|
self.style.overflowX === 'scroll';
|
|
181
187
|
self.scrollBox.horizontalBoxVisible = dataWidth > self.scrollBox.width;
|
|
182
188
|
self.scrollBox.verticalBarVisible =
|
|
183
|
-
((self.style.height
|
|
189
|
+
((!isAutoSize(self.style.height) || constrained.height) &&
|
|
184
190
|
dataHeight > self.scrollBox.height &&
|
|
185
191
|
self.style.overflowY !== 'hidden') ||
|
|
186
192
|
self.style.overflowY === 'scroll';
|
|
@@ -192,8 +198,13 @@ export default function (self) {
|
|
|
192
198
|
self.scrollBox.height =
|
|
193
199
|
self.height - columnHeaderCellHeight - topGroupAreaHeight;
|
|
194
200
|
}
|
|
201
|
+
// sizes the DOM canvas element and reads back the size the grid got
|
|
195
202
|
function setCanvasSize() {
|
|
196
203
|
if (self.isChildGrid) {
|
|
204
|
+
// a child grid fills the tree row or cell that holds it
|
|
205
|
+
self.autoSizeConstrained = { width: true, height: true };
|
|
206
|
+
self.width = self.parentNode.offsetWidth;
|
|
207
|
+
self.height = self.parentNode.offsetHeight;
|
|
197
208
|
return;
|
|
198
209
|
}
|
|
199
210
|
dims = {
|
|
@@ -206,34 +217,39 @@ export default function (self) {
|
|
|
206
217
|
1,
|
|
207
218
|
width: dataWidth + rowHeaderCellWidth + cellBorder + leftGroupAreaWidth,
|
|
208
219
|
};
|
|
209
|
-
// Browsers refuse to paint canvases beyond roughly 16k px per side, so
|
|
210
|
-
// an auto-sized grid with enough rows went blank past that point
|
|
211
|
-
// (#254). Cap the element and let it scroll for the remainder.
|
|
212
220
|
var maxCanvasSize = self.attributes.maxCanvasSize;
|
|
213
|
-
self.
|
|
214
|
-
['width', 'height'].forEach(function (dim) {
|
|
215
|
-
if (dims[dim] > maxCanvasSize) {
|
|
216
|
-
dims[dim] = maxCanvasSize;
|
|
217
|
-
self.autoSizeCapped[dim] = true;
|
|
218
|
-
}
|
|
219
|
-
});
|
|
221
|
+
self.autoSizeConstrained = { width: false, height: false };
|
|
220
222
|
['width', 'height'].forEach(function (dim) {
|
|
223
|
+
var styleIsAuto = isAutoSize(self.style[dim]),
|
|
224
|
+
inlineIsAuto = isAutoSize(self.appliedInlineStyles[dim]),
|
|
225
|
+
size;
|
|
221
226
|
//TODO: support inherit
|
|
222
|
-
if (
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
227
|
+
if (styleIsAuto && inlineIsAuto) {
|
|
228
|
+
// No explicit size: fill the container when it has a size of its
|
|
229
|
+
// own in this dimension, otherwise fit the content but never grow
|
|
230
|
+
// past the viewport. Browsers also refuse to paint canvases beyond
|
|
231
|
+
// roughly 16k px per side (#254), so cap the element there too and
|
|
232
|
+
// let the grid scroll for the remainder.
|
|
233
|
+
size = dims[dim];
|
|
234
|
+
if (containerSpace[dim] !== undefined) {
|
|
235
|
+
size = containerSpace[dim];
|
|
236
|
+
} else {
|
|
237
|
+
size = Math.min(
|
|
238
|
+
size,
|
|
239
|
+
dim === 'height' ? window.innerHeight : window.innerWidth,
|
|
240
|
+
);
|
|
234
241
|
}
|
|
242
|
+
size = Math.max(0, Math.min(size, maxCanvasSize));
|
|
243
|
+
self.autoSizeConstrained[dim] = size < dims[dim];
|
|
244
|
+
self.parentNodeStyle[dim] = size + 'px';
|
|
245
|
+
} else if (!styleIsAuto && !inlineIsAuto) {
|
|
246
|
+
self.parentNodeStyle[dim] = self.style[dim];
|
|
235
247
|
}
|
|
236
248
|
});
|
|
249
|
+
self.width = self.canvas.offsetWidth;
|
|
250
|
+
self.height = self.canvas.offsetHeight;
|
|
251
|
+
self.canvasOffsetLeft = self.args.canvasOffsetLeft || 0;
|
|
252
|
+
self.canvasOffsetTop = self.args.canvasOffsetTop || 0;
|
|
237
253
|
}
|
|
238
254
|
self.autoLastColumnWidth = undefined;
|
|
239
255
|
dataWidth = self.refreshScrollCacheX();
|
|
@@ -255,18 +271,6 @@ export default function (self) {
|
|
|
255
271
|
dataHeight += self.style.cellHeight;
|
|
256
272
|
}
|
|
257
273
|
setCanvasSize();
|
|
258
|
-
if (self.isChildGrid) {
|
|
259
|
-
self.width = self.parentNode.offsetWidth;
|
|
260
|
-
self.height = self.parentNode.offsetHeight;
|
|
261
|
-
} else if (
|
|
262
|
-
self.height !== self.canvas.offsetHeight ||
|
|
263
|
-
self.width !== self.canvas.offsetWidth
|
|
264
|
-
) {
|
|
265
|
-
self.height = self.canvas.offsetHeight;
|
|
266
|
-
self.width = self.canvas.offsetWidth;
|
|
267
|
-
self.canvasOffsetLeft = self.args.canvasOffsetLeft || 0;
|
|
268
|
-
self.canvasOffsetTop = self.args.canvasOffsetTop || 0;
|
|
269
|
-
}
|
|
270
274
|
/// calculate scroll bar dimensions
|
|
271
275
|
// non-controversial
|
|
272
276
|
self.scrollBox.top =
|
|
@@ -279,18 +283,12 @@ export default function (self) {
|
|
|
279
283
|
// if the scroll box is visible, make room for it by expanding the size of the element
|
|
280
284
|
// if the other dimension is set to auto
|
|
281
285
|
if (self.scrollBox.horizontalBarVisible) {
|
|
282
|
-
if (self.style.height === 'auto' && !self.isChildGrid) {
|
|
283
|
-
self.height += sbw;
|
|
284
|
-
}
|
|
285
286
|
dataHeight += sbw;
|
|
286
287
|
setCanvasSize();
|
|
287
288
|
setScrollBoxSize();
|
|
288
289
|
checkScrollBoxVisibility();
|
|
289
290
|
}
|
|
290
291
|
if (self.scrollBox.verticalBarVisible) {
|
|
291
|
-
if (self.style.width === 'auto' && !self.isChildGrid) {
|
|
292
|
-
self.width += sbw;
|
|
293
|
-
}
|
|
294
292
|
dataWidth += sbw;
|
|
295
293
|
setCanvasSize();
|
|
296
294
|
setScrollBoxSize();
|
|
@@ -1971,16 +1969,41 @@ export default function (self) {
|
|
|
1971
1969
|
var l,
|
|
1972
1970
|
t,
|
|
1973
1971
|
ev = e,
|
|
1972
|
+
childEvent,
|
|
1974
1973
|
deltaX = e.deltaX === undefined ? e.NativeEvent.deltaX : e.deltaX,
|
|
1975
1974
|
deltaY = e.deltaY === undefined ? e.NativeEvent.deltaY : e.deltaY,
|
|
1976
1975
|
deltaMode =
|
|
1977
1976
|
e.deltaMode === undefined ? e.NativeEvent.deltaMode : e.deltaMode;
|
|
1978
1977
|
if (e.NativeEvent) e = e.NativeEvent;
|
|
1978
|
+
if (self.disposed) {
|
|
1979
|
+
return;
|
|
1980
|
+
}
|
|
1981
|
+
// A child grid receives the wheel through its parent's `wheel` grid
|
|
1982
|
+
// event (`ev`), not from the DOM. Cancelling and marking that event tells
|
|
1983
|
+
// every ancestor that the grid under the pointer owns this wheel, so only
|
|
1984
|
+
// the hovered grid scrolls, even when it has nothing left to scroll.
|
|
1985
|
+
function claim() {
|
|
1986
|
+
if (ev !== e) {
|
|
1987
|
+
ev.claimedByChildGrid = true;
|
|
1988
|
+
ev.preventDefault();
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1979
1991
|
if (wheeling) {
|
|
1980
|
-
ev
|
|
1992
|
+
if (ev === e) {
|
|
1993
|
+
e.preventDefault();
|
|
1994
|
+
} else {
|
|
1995
|
+
claim();
|
|
1996
|
+
}
|
|
1981
1997
|
return;
|
|
1982
1998
|
}
|
|
1983
|
-
if (self.
|
|
1999
|
+
if (self.hasFocus) {
|
|
2000
|
+
claim();
|
|
2001
|
+
}
|
|
2002
|
+
childEvent = { NativeEvent: e };
|
|
2003
|
+
if (self.dispatchEvent('wheel', childEvent)) {
|
|
2004
|
+
if (childEvent.claimedByChildGrid) {
|
|
2005
|
+
claim();
|
|
2006
|
+
}
|
|
1984
2007
|
return;
|
|
1985
2008
|
}
|
|
1986
2009
|
self.touchHaltAnimation = true;
|
package/lib/intf.js
CHANGED
|
@@ -749,7 +749,12 @@ export default function (self, ctor) {
|
|
|
749
749
|
self.eventParent.removeEventListener('dblclick', self.dblclick, false);
|
|
750
750
|
self.eventParent.removeEventListener('click', self.click, false);
|
|
751
751
|
self.eventParent.removeEventListener('mousemove', self.mousemove);
|
|
752
|
-
|
|
752
|
+
// child grids listen for the wheel on the parent grid's event, not the DOM
|
|
753
|
+
self[self.isChildGrid ? 'parentGrid' : 'eventParent'].removeEventListener(
|
|
754
|
+
'wheel',
|
|
755
|
+
self.scrollWheel,
|
|
756
|
+
false,
|
|
757
|
+
);
|
|
753
758
|
self.canvas.removeEventListener(
|
|
754
759
|
'contextmenu',
|
|
755
760
|
self.contextmenuEvent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "canvas-datagrid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Canvas based data grid web component. Capable of displaying millions of contiguous hierarchical rows and columns without paging or loading, on a single canvas element.",
|
|
5
5
|
"main": "./dist/canvas-datagrid.js",
|
|
6
6
|
"module": "./dist/canvas-datagrid.module.js",
|