canvas-datagrid 0.25.4 → 0.26.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/touch.js CHANGED
@@ -144,41 +144,6 @@ export default function (self) {
144
144
  self.touchEditCell = function (cell) {
145
145
  self.beginEditAt(cell.columnIndex, cell.rowIndex);
146
146
  };
147
- self.touchCell = function (e) {
148
- return function () {
149
- clearInterval(self.calculatePPSTimer);
150
- var i,
151
- pos = self.getTouchPos(e);
152
- if (
153
- Math.abs(self.touchDelta.x) + Math.abs(self.touchDelta.y) <
154
- self.attributes.touchDeadZone
155
- ) {
156
- i = self.getCellAt(pos.x, pos.y);
157
- if (!i) {
158
- return;
159
- }
160
- if (
161
- self.touchingCell &&
162
- self.touchingCell.rowIndex === i.rowIndex &&
163
- self.touchingCell.columnIndex === i.columnIndex
164
- ) {
165
- self.touchEditCell(i);
166
- return;
167
- }
168
- if (self.input && self.input.editCell) {
169
- self.endEdit();
170
- }
171
- self.touchingCell = i;
172
- self.selectArea({
173
- top: i.rowIndex,
174
- bottom: i.rowIndex,
175
- left: i.columnIndex,
176
- right: i.columnIndex,
177
- });
178
- self.draw(true);
179
- }
180
- };
181
- };
182
147
  self.touchstart = function (e) {
183
148
  if (e.changedTouches[0]) {
184
149
  self.touchStart = self.getTouchPos(e);
@@ -187,6 +152,10 @@ export default function (self) {
187
152
  self.touchStart.y,
188
153
  true,
189
154
  );
155
+ } else {
156
+ // nothing to start from (#554)
157
+ self.startingCell = undefined;
158
+ return;
190
159
  }
191
160
  if (
192
161
  self.dispatchEvent('touchstart', {
@@ -203,7 +172,6 @@ export default function (self) {
203
172
  self.stopAnimation = true;
204
173
  self.animationFrames = 0;
205
174
  self.stopPropagation(e);
206
- e.preventDefault();
207
175
  if (e.touches.length === 1 && e.changedTouches[0] && !self.zoomAltered) {
208
176
  self.touchLength = 1;
209
177
  self.touchStart = self.touchStart || self.touchStart1;
@@ -245,7 +213,7 @@ export default function (self) {
245
213
  return;
246
214
  }
247
215
  self.hasFocus = true;
248
- if (self.startingCell.isHeader) {
216
+ if (self.startingCell && self.startingCell.isHeader) {
249
217
  if (self.startingCell.isRowHeader) {
250
218
  self.selectArea({
251
219
  top: self.startingCell.rowIndex,
@@ -264,10 +232,13 @@ export default function (self) {
264
232
  }
265
233
  self.order(self.startingCell.header.name, self.orderDirection);
266
234
  }
267
- if (self.attributes.columnHeaderClickBehavior === 'select') {
235
+ if (
236
+ self.attributes.columnHeaderClickBehavior === 'select' &&
237
+ self.attributes.allowColumnSelection
238
+ ) {
268
239
  self.selectArea({
269
240
  top: 0,
270
- bottom: self.data.length - 1,
241
+ bottom: self.viewData.length - 1,
271
242
  left: self.startingCell.columnIndex,
272
243
  right: self.startingCell.columnIndex,
273
244
  });
@@ -425,21 +396,24 @@ export default function (self) {
425
396
  ) {
426
397
  touchScroll();
427
398
  }
428
- if (/vertical-scroll-/.test(self.startingCell.style)) {
399
+ // the starting cell can be missing when the touch began off-grid (#554)
400
+ var startingCellStyle =
401
+ (self.startingCell && self.startingCell.style) || '';
402
+ if (/vertical-scroll-/.test(startingCellStyle)) {
429
403
  self.scrollBox.scrollTop =
430
404
  self.scrollBox.scrollHeight *
431
405
  ((self.touchPosition.y - ch - sbw) /
432
406
  (self.scrollBox.height - sbw - ch));
433
407
  return;
434
408
  }
435
- if (/horizontal-scroll-/.test(self.startingCell.style)) {
409
+ if (/horizontal-scroll-/.test(startingCellStyle)) {
436
410
  self.scrollBox.scrollLeft =
437
411
  self.scrollBox.scrollWidth *
438
412
  ((self.touchPosition.x - rw - sbw) / (self.scrollBox.width - sbw - rw));
439
413
  return;
440
414
  }
441
- if (/selection-handle-/.test(self.startingCell.style)) {
442
- self.touchSelect(self.currentCell, self.startingCell.style);
415
+ if (/selection-handle-/.test(startingCellStyle)) {
416
+ self.touchSelect(self.currentCell, startingCellStyle);
443
417
  return;
444
418
  }
445
419
  self.scrollBox.scrollTo(
@@ -509,13 +483,12 @@ export default function (self) {
509
483
  self.touchAnimateTo.y =
510
484
  self.yPPS * self.attributes.touchReleaseAcceleration;
511
485
  self.calculatePPSTimed();
512
- if (dz && !self.contextMenu) {
513
- self.touchCell(self.touchStartEvent)();
514
- } else if (
486
+ if (
487
+ !dz &&
515
488
  self.animationFrames === 0 &&
516
489
  (Math.abs(self.xPPST) > self.attributes.scrollAnimationPPSThreshold ||
517
490
  Math.abs(self.yPPST) > self.attributes.scrollAnimationPPSThreshold) &&
518
- !/-scroll-/.test(self.startingCell.style) &&
491
+ !/-scroll-/.test((self.startingCell && self.startingCell.style) || '') &&
519
492
  !dz
520
493
  ) {
521
494
  self.stopAnimation = false;
package/package.json CHANGED
@@ -1,17 +1,25 @@
1
1
  {
2
2
  "name": "canvas-datagrid",
3
- "version": "0.25.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.",
3
+ "version": "0.26.0",
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",
7
7
  "scripts": {
8
8
  "build": "rollup -c && webpack",
9
- "build-docs": "rm -rf docs; npm run build; jsdoc -c ./jsdoc.conf.js; cp dist/canvas-datagrid.* docs/; cp -r tutorials/* images docs/",
9
+ "postbuild": "npm run build:types",
10
+ "prebuild:docs": "node docs/jsdoc-to-md.js",
11
+ "build:docs": "cd docs && npm run build",
10
12
  "format": "prettier lib/**/*.js --write",
11
13
  "lint": "eslint lib",
12
- "test": "npm run build; karma start",
13
- "watch": "webpack --watch"
14
+ "test": "npm run build && npm run test:types && npm run test:bundle && karma start",
15
+ "test:watch": "karma start --no-single-run",
16
+ "watch": "webpack --watch",
17
+ "build:types": "jsdoc -c ./jsdoc.ts.conf.js && node ./scripts/finalize-types.js",
18
+ "start": "webpack serve --open",
19
+ "test:types": "tsc -p ./test/types/tsconfig.json",
20
+ "test:bundle": "node ./scripts/check-no-eval.js"
14
21
  },
22
+ "types": "./dist/types.d.ts",
15
23
  "files": [
16
24
  "dist/*",
17
25
  "lib/*",
@@ -34,7 +42,8 @@
34
42
  "component"
35
43
  ],
36
44
  "browserslist": [
37
- "defaults"
45
+ "defaults",
46
+ "not IE 11"
38
47
  ],
39
48
  "author": "Tony Germaneri <Tony.Germaneri@gmail.com>",
40
49
  "contributors": [
@@ -66,26 +75,31 @@
66
75
  "@rollup/plugin-node-resolve": "^10.0.0",
67
76
  "@rollup/plugin-replace": "^2.3.4",
68
77
  "babel-loader": "^8.2.1",
78
+ "chai": "^4.2.0",
69
79
  "eslint": "^7.14.0",
70
80
  "eslint-config-prettier": "^6.15.0",
71
81
  "eslint-plugin-prettier": "^3.1.4",
72
- "husky": "^4.3.0",
82
+ "husky": "^8.0.3",
73
83
  "istanbul": "^0.4.5",
74
84
  "jsdoc": "^3.6.6",
75
- "karma": "^5.2.3",
85
+ "karma": "^6.3.14",
86
+ "karma-chai": "^0.1.0",
76
87
  "karma-chrome-launcher": "^3.1.0",
77
88
  "karma-coverage": "^2.0.2",
78
89
  "karma-coverage-istanbul-reporter": "^3.0.2",
79
90
  "karma-mocha": "^2.0.1",
80
- "lint-staged": "^10.5.2",
91
+ "lint-staged": "^13.2.1",
81
92
  "marked": "^1.2.5",
82
93
  "mocha": "^8.2.1",
83
94
  "prettier": "^2.2.0",
84
95
  "rollup": "^2.33.3",
85
96
  "rollup-plugin-clear": "^2.0.7",
86
97
  "rollup-plugin-terser": "^7.0.2",
98
+ "tsd-jsdoc": "^2.5.0",
99
+ "typescript": "^5.9.3",
87
100
  "webpack": "^5.6.0",
88
- "webpack-cli": "^4.2.0"
101
+ "webpack-cli": "^4.2.0",
102
+ "webpack-dev-server": "^3.11.1"
89
103
  },
90
104
  "dependencies": {
91
105
  "is-printable-key-event": "1.0.0"