datatables.net-scroller
Advanced tools
Comparing version 1.4.2 to 1.4.3
@@ -1,3 +0,3 @@ | ||
/*! Scroller 1.4.2 | ||
* ©2011-2016 SpryMedia Ltd - datatables.net/license | ||
/*! Scroller 1.4.3 | ||
* ©2011-2017 SpryMedia Ltd - datatables.net/license | ||
*/ | ||
@@ -8,7 +8,7 @@ | ||
* @description Virtual rendering for DataTables | ||
* @version 1.4.2 | ||
* @version 1.4.3 | ||
* @file dataTables.scroller.js | ||
* @author SpryMedia Ltd (www.sprymedia.co.uk) | ||
* @contact www.sprymedia.co.uk/contact | ||
* @copyright Copyright 2011-2016 SpryMedia Ltd. | ||
* @copyright Copyright 2011-2017 SpryMedia Ltd. | ||
* | ||
@@ -214,3 +214,4 @@ * This source file is free software, available under the following license: | ||
scrollDrawDiff: null, | ||
loaderVisible: false | ||
loaderVisible: false, | ||
forceReposition: false | ||
}; | ||
@@ -376,2 +377,10 @@ | ||
px = this.fnRowToPixels( iRow, false, true ); | ||
// If we need records outside the current draw region, but the new | ||
// scrolling position is inside that (due to the non-linear nature | ||
// for larger numbers of records), we need to force position update. | ||
if ( this.s.redrawTop < px && px < this.s.redrawBottom ) { | ||
this.s.forceReposition = true; | ||
bAnimate = false; | ||
} | ||
} | ||
@@ -438,3 +447,11 @@ | ||
if ( heights.row ) { | ||
heights.viewport = $(this.dom.scroller).height(); | ||
heights.viewport = $.contains(document, this.dom.scroller) ? | ||
$(this.dom.scroller).height() : | ||
this._parseHeight($(this.dom.scroller).css('height')); | ||
// If collapsed (no height) use the max-height parameter | ||
if ( ! heights.viewport ) { | ||
heights.viewport = this._parseHeight($(this.dom.scroller).css('max-height')); | ||
} | ||
this.s.viewportRows = parseInt( heights.viewport / heights.row, 10 )+1; | ||
@@ -663,6 +680,7 @@ this.s.dt._iDisplayLength = this.s.viewportRows * this.s.displayBuffer; | ||
*/ | ||
if ( iScrollTop < this.s.redrawTop || iScrollTop > this.s.redrawBottom ) { | ||
if ( this.s.forceReposition || iScrollTop < this.s.redrawTop || iScrollTop > this.s.redrawBottom ) { | ||
var preRows = Math.ceil( ((this.s.displayBuffer-1)/2) * this.s.viewportRows ); | ||
if ( Math.abs( iScrollTop - this.s.lastScrollTop ) > heights.viewport || this.s.ani ) { | ||
if ( Math.abs( iScrollTop - this.s.lastScrollTop ) > heights.viewport || this.s.ani || this.s.forceReposition ) { | ||
iTopRow = parseInt(this._domain( 'physicalToVirtual', iScrollTop ) / heights.row, 10) - preRows; | ||
@@ -676,2 +694,4 @@ this.s.topRowFloat = this._domain( 'physicalToVirtual', iScrollTop ) / heights.row; | ||
this.s.forceReposition = false; | ||
if ( iTopRow <= 0 ) { | ||
@@ -792,3 +812,42 @@ /* At the start of the table */ | ||
/** | ||
* Parse CSS height property string as number | ||
* | ||
* An attempt is made to parse the string as a number. Currently supported units are 'px', | ||
* 'vh', and 'rem'. 'em' is partially supported; it works as long as the parent element's | ||
* font size matches the body element. Zero is returned for unrecognized strings. | ||
* @param {string} cssHeight CSS height property string | ||
* @returns {number} height | ||
* @private | ||
*/ | ||
_parseHeight: function(cssHeight) { | ||
var height; | ||
var matches = /^([+-]?(?:\d+(?:\.\d+)?|\.\d+))(px|em|rem|vh)$/.exec(cssHeight); | ||
if (matches === null) { | ||
return 0; | ||
} | ||
var value = parseFloat(matches[1]); | ||
var unit = matches[2]; | ||
if ( unit === 'px' ) { | ||
height = value; | ||
} | ||
else if ( unit === 'vh' ) { | ||
height = ( value / 100 ) * $(window).height(); | ||
} | ||
else if ( unit === 'rem' ) { | ||
height = value * parseFloat($(':root').css('font-size')); | ||
} | ||
else if ( unit === 'em' ) { | ||
height = value * parseFloat($('body').css('font-size')); | ||
} | ||
return height ? | ||
height : | ||
0; | ||
}, | ||
/** | ||
@@ -860,3 +919,5 @@ * Draw callback function which is fired when the DataTable is redrawn. The main function of | ||
this.s.redrawTop = iScrollTop - boundaryPx; | ||
this.s.redrawBottom = iScrollTop + boundaryPx; | ||
this.s.redrawBottom = iScrollTop + boundaryPx > heights.scroll - heights.viewport - heights.row ? | ||
heights.scroll - heights.viewport - heights.row : | ||
iScrollTop + boundaryPx; | ||
@@ -1228,3 +1289,3 @@ this.s.skip = false; | ||
*/ | ||
Scroller.version = "1.4.2"; | ||
Scroller.version = "1.4.3"; | ||
@@ -1231,0 +1292,0 @@ |
{ | ||
"name": "datatables.net-scroller", | ||
"version": "1.4.2", | ||
"version": "1.4.3", | ||
"description": "Scroller for DataTables ", | ||
"files": [ | ||
"js/dataTables.scroller.js" | ||
"js/**/*.js" | ||
], | ||
@@ -25,3 +25,3 @@ "main": "./js/dataTables.scroller.js", | ||
"jquery": ">=1.7", | ||
"datatables.net": ">=1.10.9" | ||
"datatables.net": "^1.10.15" | ||
}, | ||
@@ -28,0 +28,0 @@ "repository": { |
# Scroller for DataTables | ||
This package contains distribution files for the [Scroller extension](https://datatables.net/extensions/scroller) for [DataTables](https://datatables.net/). Only the core software for this library is contained in this package - to be correctly styled, a styling package for Scroller must also be included. Styling options include DataTable's native styling, [Bootstrap](http://getboostrap.com) and [Foundation](http://foundation.zurb.com/). | ||
This package contains distribution files for the [Scroller extension](https://datatables.net/extensions/scroller) for [DataTables](https://datatables.net/). Only the core software for this library is contained in this package - to be correctly styled, a styling package for Scroller must also be included. Styling options include DataTable's native styling, [Bootstrap](http://getbootstrap.com) and [Foundation](http://foundation.zurb.com/). | ||
@@ -5,0 +5,0 @@ Scroller is a virtual rendering plug-in for DataTables which allows large datasets to be drawn on screen very quickly. Virtual rendering means is that only the visible portion of the table is drawn, while the scrolling container gives the visual impression that the whole table is visible, allowing excellent browser performance. |
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
57746
4
1287
1
+ Addeddatatables.net@1.13.11(transitive)
- Removeddatatables.net@2.2.2(transitive)
Updateddatatables.net@^1.10.15