jquery.dgtable 0.6.0 → 0.6.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jquery.dgtable",
3
3
  "description": "High-performance table View for jQuery",
4
- "version": "0.6.0",
4
+ "version": "0.6.1",
5
5
  "main": "dist/jquery.dgtable.cjs.min.js",
6
6
  "module": "dist/jquery.dgtable.es6.min.js",
7
7
  "broswer": "dist/jquery.dgtable.umd.min.js",
package/src/index.js CHANGED
@@ -145,7 +145,7 @@ DGTable.prototype.initialize = function (options) {
145
145
  /**
146
146
  * @private
147
147
  * @field {number} estimatedRowHeight */
148
- o.estimatedRowHeight = options.estimatedRowHeight === undefined ? 40 : options.estimatedRowHeight;
148
+ o.estimatedRowHeight = options.estimatedRowHeight || undefined;
149
149
 
150
150
  /**
151
151
  * @private
@@ -407,7 +407,7 @@ DGTable.prototype._setupVirtualTable = function () {
407
407
  autoVirtualWrapperWidth: false,
408
408
  virtual: true,
409
409
  buffer: o.rowsBufferSize,
410
- estimatedItemHeight: o.estimatedRowHeight || 40,
410
+ estimatedItemHeight: o.estimatedRowHeight ? o.estimatedRowHeight : (p.virtualRowHeight || 40),
411
411
  itemElementCreatorFn: () => {
412
412
  return createElement('div');
413
413
  },
@@ -3344,6 +3344,41 @@ DGTable.prototype._renderSkeletonBody = function () {
3344
3344
 
3345
3345
  let tableClassName = o.tableClassName;
3346
3346
 
3347
+ // Calculate virtual row heights
3348
+ if (o.virtualTable && !p.virtualRowHeight) {
3349
+ let createDummyRow = function() {
3350
+ let row = createElement('div'),
3351
+ cell = row.appendChild(createElement('div')),
3352
+ cellInner = cell.appendChild(createElement('div'));
3353
+ row.className = tableClassName + '-row';
3354
+ cell.className = tableClassName + '-cell';
3355
+ cellInner.innerHTML = '0';
3356
+ row.style.visibility = 'hidden';
3357
+ row.style.position = 'absolute';
3358
+ return row;
3359
+ };
3360
+
3361
+ let $dummyTbody, $dummyWrapper = $('<div>')
3362
+ .addClass(that.el.className)
3363
+ .css({ 'z-index': -1, 'position': 'absolute', left: '0', top: '-9999px', width: '1px', overflow: 'hidden' })
3364
+ .append(
3365
+ $('<div>').addClass(tableClassName).append(
3366
+ $dummyTbody = $('<div>').addClass(tableClassName + '-body').css('width', 99999),
3367
+ ),
3368
+ );
3369
+
3370
+ $dummyWrapper.appendTo(document.body);
3371
+
3372
+ let row1 = createDummyRow(), row2 = createDummyRow(), row3 = createDummyRow();
3373
+ $dummyTbody.append(row1, row2, row3);
3374
+
3375
+ p.virtualRowHeightFirst = getElementHeight(row1, true, true, true);
3376
+ p.virtualRowHeight = getElementHeight(row2, true, true, true);
3377
+ p.virtualRowHeightLast = getElementHeight(row3, true, true, true);
3378
+
3379
+ $dummyWrapper.remove();
3380
+ }
3381
+
3347
3382
  // Create inner table and tbody
3348
3383
  if (!p.$table) {
3349
3384
 
@@ -3420,7 +3455,7 @@ DGTable.prototype._updateVirtualHeight = function() {
3420
3455
  }
3421
3456
 
3422
3457
  return this;
3423
- }
3458
+ };
3424
3459
 
3425
3460
  /**
3426
3461
  * @private