datatables.net-scroller
Advanced tools
Comparing version 2.3.0 to 2.4.0
@@ -1,2 +0,2 @@ | ||
/*! Scroller 2.3.0 | ||
/*! Scroller 2.4.0 | ||
* © SpryMedia Ltd - datatables.net/license | ||
@@ -46,3 +46,3 @@ */ | ||
} | ||
}(function( $, window, document, undefined ) { | ||
}(function( $, window, document ) { | ||
'use strict'; | ||
@@ -56,3 +56,3 @@ var DataTable = $.fn.dataTable; | ||
* @description Virtual rendering for DataTables | ||
* @version 2.3.0 | ||
* @version 2.4.0 | ||
* @copyright SpryMedia Ltd. | ||
@@ -72,3 +72,3 @@ * | ||
* Scroller is a virtual rendering plug-in for DataTables which allows large | ||
* datasets to be drawn on screen every quickly. What the virtual rendering means | ||
* datasets to be drawn on screen very quickly. What the virtual rendering means | ||
* is that only the visible portion of the table (and a bit to either side to make | ||
@@ -544,5 +544,3 @@ * the scrolling smooth) is drawn, while the scrolling container gives the | ||
topRow: that.s.topRowFloat, | ||
baseScrollTop: that.s.baseScrollTop, | ||
baseRowTop: that.s.baseRowTop, | ||
scrollTop: that.s.lastScrollTop | ||
baseRowTop: that.s.baseRowTop | ||
}; | ||
@@ -558,10 +556,15 @@ } | ||
this.measure(false); | ||
if (loadedState && loadedState.scroller) { | ||
this.s.topRowFloat = loadedState.scroller.topRow; | ||
this.s.baseScrollTop = loadedState.scroller.baseScrollTop; | ||
this.s.baseRowTop = loadedState.scroller.baseRowTop; | ||
// Reconstruct the scroll positions from the rows - it is possible the | ||
// row height has changed e.g. if the styling framework has changed. | ||
// The scroll top is used in `_draw` further down. | ||
this.s.baseScrollTop = this.s.baseRowTop * this.s.heights.row; | ||
loadedState.scroller.scrollTop = this._domain('physicalToVirtual', this.s.topRowFloat * this.s.heights.row); | ||
} | ||
this.measure(false); | ||
that.s.stateSaveThrottle = DataTable.util.throttle(function () { | ||
@@ -713,4 +716,4 @@ that.s.dtApi.state.save(); | ||
? this._domain( | ||
'virtualToPhysical', | ||
this.s.topRowFloat * heights.row | ||
'virtualToPhysical', | ||
this.s.topRowFloat * heights.row | ||
) | ||
@@ -886,4 +889,17 @@ : iScrollTop; | ||
total = info.recordsDisplay, | ||
max = info.recordsTotal, | ||
start = Math.floor(this.s.topRowFloat) + 1, | ||
max = info.recordsTotal; | ||
// If the scroll type is `cont` (continuous) we need to use `baseRowTop`, which | ||
// also means we need to work out the difference between the current scroll position | ||
// and the "base" for when it was required | ||
var diffRows = (this.s.lastScrollTop - this.s.baseScrollTop) / this.s.heights.row; | ||
var start = Math.floor(this.s.baseRowTop + diffRows); | ||
// For a jump scroll type, we just use the straightforward calculation based on | ||
// `topRowFloat` | ||
if (this.s.scrollType === 'jump') { | ||
start = Math.floor(this.s.topRowFloat) + 1; | ||
} | ||
var | ||
possibleEnd = start + Math.floor(this.s.heights.viewport / this.s.heights.row), | ||
@@ -911,4 +927,3 @@ end = possibleEnd > total ? total : possibleEnd, | ||
// Record set after filtering | ||
result = language.sInfo; | ||
' ' + language.sInfoFiltered + language.sInfoPostFix; | ||
result = language.sInfo + ' ' + language.sInfoFiltered + language.sInfoPostFix; | ||
} | ||
@@ -944,3 +959,3 @@ | ||
$(this).html(result); | ||
dtApi.trigger('info', [this, result]); | ||
dtApi.trigger('info', [dtApi.settings()[0], this, result]); | ||
}); | ||
@@ -1243,3 +1258,3 @@ }, | ||
* @type int | ||
* @default 7 | ||
* @default 9 | ||
* @static | ||
@@ -1282,3 +1297,3 @@ */ | ||
*/ | ||
Scroller.version = '2.3.0'; | ||
Scroller.version = '2.4.0'; | ||
@@ -1285,0 +1300,0 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -1,4 +0,4 @@ | ||
/*! Scroller 2.3.0 | ||
/*! Scroller 2.4.0 | ||
* © SpryMedia Ltd - datatables.net/license | ||
*/ | ||
!function(o){var e,r;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(t){return o(t,window,document)}):"object"==typeof exports?(e=require("jquery"),r=function(t,s){s.fn.dataTable||require("datatables.net")(t,s)},"undefined"==typeof window?module.exports=function(t,s){return t=t||window,s=s||e(t),r(t,s),o(s,t,t.document)}:(r(window,e),module.exports=o(e,window,window.document))):o(jQuery,window,document)}(function(d,i,o,a){"use strict";function e(t,s){this instanceof e?(s===a&&(s={}),t=d.fn.dataTable.Api(t),this.s={dt:t.settings()[0],dtApi:t,tableTop:0,tableBottom:0,redrawTop:0,redrawBottom:0,autoHeight:!0,viewportRows:0,stateTO:null,stateSaveThrottle:function(){},drawTO:null,heights:{jump:null,page:null,virtual:null,scroll:null,row:null,viewport:null,labelHeight:0,xbar:0},topRowFloat:0,scrollDrawDiff:null,loaderVisible:!1,forceReposition:!1,baseRowTop:0,baseScrollTop:0,mousedown:!1,lastScrollTop:0},this.s=d.extend(this.s,e.oDefaults,s),this.s.heights.row=this.s.rowHeight,this.dom={force:o.createElement("div"),label:d('<div class="dts_label">0</div>'),scroller:null,table:null,loader:null},this.s.dt.oScroller||(this.s.dt.oScroller=this).construct()):alert("Scroller warning: Scroller must be initialised with the 'new' keyword.")}var n=d.fn.dataTable,t=(d.extend(e.prototype,{measure:function(t){this.s.autoHeight&&this._calcRowHeight();var s=this.s.heights,o=(s.row&&(s.viewport=this._parseHeight(d(this.dom.scroller).css("max-height")),this.s.viewportRows=parseInt(s.viewport/s.row,10)+1,this.s.dt._iDisplayLength=this.s.viewportRows*this.s.displayBuffer),this.dom.label.outerHeight());s.xbar=this.dom.scroller.offsetHeight-this.dom.scroller.clientHeight,s.labelHeight=o,t!==a&&!t||this.s.dt.oInstance.fnDraw(!1)},pageInfo:function(){var t=this.s.dt,s=this.dom.scroller.scrollTop,t=t.fnRecordsDisplay(),o=Math.ceil(this.pixelsToRow(s+this.s.heights.viewport,!1,this.s.ani));return{start:Math.floor(this.pixelsToRow(s,!1,this.s.ani)),end:t<o?t-1:o-1}},pixelsToRow:function(t,s,o){t-=this.s.baseScrollTop,o=o?(this._domain("physicalToVirtual",this.s.baseScrollTop)+t)/this.s.heights.row:t/this.s.heights.row+this.s.baseRowTop;return s||s===a?parseInt(o,10):o},rowToPixels:function(t,s,o){t-=this.s.baseRowTop,o=o?this._domain("virtualToPhysical",this.s.baseScrollTop):this.s.baseScrollTop;return o+=t*this.s.heights.row,s||s===a?parseInt(o,10):o},scrollToRow:function(t,s){var o=this,e=!1,r=this.rowToPixels(t),l=t-(this.s.displayBuffer-1)/2*this.s.viewportRows;l<0&&(l=0),(r>this.s.redrawBottom||r<this.s.redrawTop)&&this.s.dt._iDisplayStart!==l&&(e=!0,r=this._domain("virtualToPhysical",t*this.s.heights.row),this.s.redrawTop<r&&r<this.s.redrawBottom&&(s=!(this.s.forceReposition=!0))),s===a||s?(this.s.ani=e,d(this.dom.scroller).animate({scrollTop:r},function(){setTimeout(function(){o.s.ani=!1},250)})):d(this.dom.scroller).scrollTop(r)},construct:function(){var e=this,t=this.s.dtApi;if(!this.s.dt.oFeatures.bPaginate)throw new Error("Pagination must be enabled for Scroller to operate");this.dom.force.style.position="relative",this.dom.force.style.top="0px",this.dom.force.style.left="0px",this.dom.force.style.width="1px",this.dom.scroller=t.table().node().parentNode,this.dom.scroller.appendChild(this.dom.force),this.dom.scroller.style.position="relative",this.dom.table=d(">table",this.dom.scroller)[0],this.dom.table.style.position="absolute",this.dom.table.style.top="0px",this.dom.table.style.left="0px",d(t.table().container()).addClass("dts DTS"),this.dom.label.appendTo(this.dom.scroller),this.s.heights.row&&"auto"!=this.s.heights.row&&(this.s.autoHeight=!1),this.s.ingnoreScroll=!0,d(this.dom.scroller).on("scroll.dt-scroller",function(t){e._scroll.call(e)}),d(this.dom.scroller).on("touchstart.dt-scroller",function(){e._scroll.call(e)}),d(this.dom.scroller).on("mousedown.dt-scroller",function(){e.s.mousedown=!0}).on("mouseup.dt-scroller",function(){e.s.labelVisible=!1,e.s.mousedown=!1,e.dom.label.css("display","none")}),d(i).on("resize.dt-scroller",function(){e.measure(!1),e._info()});var r=!0,l=t.state.loaded();t.on("stateSaveParams.scroller",function(t,s,o){r&&l?(o.scroller=l.scroller,r=!1,o.scroller&&(e.s.lastScrollTop=o.scroller.scrollTop)):o.scroller={topRow:e.s.topRowFloat,baseScrollTop:e.s.baseScrollTop,baseRowTop:e.s.baseRowTop,scrollTop:e.s.lastScrollTop}}),t.on("stateLoadParams.scroller",function(t,s,o){o.scroller!==a&&e.scrollToRow(o.scroller.topRow)}),l&&l.scroller&&(this.s.topRowFloat=l.scroller.topRow,this.s.baseScrollTop=l.scroller.baseScrollTop,this.s.baseRowTop=l.scroller.baseRowTop),this.measure(!1),e.s.stateSaveThrottle=n.util.throttle(function(){e.s.dtApi.state.save()},500),t.on("init.scroller",function(){e.measure(!1),e.s.scrollType="jump",e._draw(),t.on("draw.scroller",function(){e._draw()})}),t.on("preDraw.dt.scroller",function(){e._scrollForce()}),t.on("destroy.scroller",function(){d(i).off("resize.dt-scroller"),d(e.dom.scroller).off(".dt-scroller"),d(e.s.dt.nTable).off(".scroller"),d(e.s.dt.nTableWrapper).removeClass("DTS"),d("div.DTS_Loading",e.dom.scroller.parentNode).remove(),e.dom.table.style.position="",e.dom.table.style.top="",e.dom.table.style.left=""})},_calcRowHeight:function(){var t=this.s.dt,s=t.nTable,o=s.cloneNode(!1),e=d("<tbody/>").appendTo(o),t=t.oClasses,t=n.versionCheck("2")?{container:t.container,scroller:t.scrolling.container,body:t.scrolling.body}:{container:t.sWrapper,scroller:t.sScrollWrapper,body:t.sScrollBody},r=d('<div class="'+t.container+' DTS"><div class="'+t.scroller+'"><div class="'+t.body+'"></div></div></div>'),l=(d("tbody tr:lt(4)",s).clone().appendTo(e),d("tr",e).length);if(1===l)e.prepend("<tr><td> </td></tr>"),e.append("<tr><td> </td></tr>");else for(;l<3;l++)e.append("<tr><td> </td></tr>");d("div."+t.body,r).append(o);t=this.s.dt.nHolding||s.parentNode;d(t).is(":visible")||(t="body"),r.find("input").removeAttr("name"),r.appendTo(t),this.s.heights.row=d("tr",e).eq(1).outerHeight(),r.remove()},_draw:function(){var t=this,s=this.s.heights,o=this.dom.scroller.scrollTop,e=d(this.s.dt.nTable).height(),r=this.s.dt._iDisplayStart,l=this.s.dt._iDisplayLength,i=this.s.dt.fnRecordsDisplay(),a=o+s.viewport,n=(this.s.skip=!0,!this.s.dt.bSorted&&!this.s.dt.bFiltered||0!==r||this.s.dt._drawHold||(this.s.topRowFloat=0),o="jump"===this.s.scrollType?this._domain("virtualToPhysical",this.s.topRowFloat*s.row):o,this.s.baseScrollTop=o,this.s.baseRowTop=this.s.topRowFloat,o-(this.s.topRowFloat-r)*s.row),r=(0===r?n=0:i<=r+l?n=s.scroll-e:n+e<a&&(this.s.baseScrollTop+=1+((i=a-e)-n),n=i),this.dom.table.style.top=n+"px",this.s.tableTop=n,this.s.tableBottom=e+this.s.tableTop,(o-this.s.tableTop)*this.s.boundaryScale);this.s.redrawTop=o-r,this.s.redrawBottom=o+r>s.scroll-s.viewport-s.row?s.scroll-s.viewport-s.row:o+r,this.s.skip=!1,t.s.ingnoreScroll&&(this.s.dt.oFeatures.bStateSave&&null!==this.s.dt.oLoadedState&&void 0!==this.s.dt.oLoadedState.scroller?((l=!(!this.s.dt.sAjaxSource&&!t.s.dt.ajax||this.s.dt.oFeatures.bServerSide))&&2<=this.s.dt.iDraw||!l&&1<=this.s.dt.iDraw)&&setTimeout(function(){d(t.dom.scroller).scrollTop(t.s.dt.oLoadedState.scroller.scrollTop),setTimeout(function(){t.s.ingnoreScroll=!1},0)},0):t.s.ingnoreScroll=!1),this.s.dt.oFeatures.bInfo&&setTimeout(function(){t._info.call(t)},0),d(this.s.dt.nTable).triggerHandler("position.dts.dt",n)},_domain:function(t,s){var o,e=this.s.heights,r=1e4;return e.virtual===e.scroll||s<r?s:"virtualToPhysical"===t&&s>=e.virtual-r?(o=e.virtual-s,e.scroll-o):"physicalToVirtual"===t&&s>=e.scroll-r?(o=e.scroll-s,e.virtual-o):(e=r-(o=(e.virtual-r-r)/(e.scroll-r-r))*r,"virtualToPhysical"===t?(s-e)/o:o*s+e)},_info:function(){if(this.s.dt.oFeatures.bInfo){var t,s=this.s.dt,o=this.s.dtApi,e=s.oLanguage,r=o.page.info(),l=r.recordsDisplay,r=r.recordsTotal,i=Math.floor(this.s.topRowFloat)+1,a=i+Math.floor(this.s.heights.viewport/this.s.heights.row),a=l<a?l:a,e=(0===l&&l==r?t=e.sInfoEmpty+e.sInfoPostFix:0===l?t=e.sInfoEmpty+" "+e.sInfoFiltered+e.sInfoPostFix:l==r?t=e.sInfo+e.sInfoPostFix:(t=e.sInfo,e.sInfoFiltered,e.sInfoPostFix),t=this._macros(t,i,a,r,l),e.fnInfoCallback),n=(e&&(t=e.call(s.oInstance,s,i,a,r,l,t)),s.aanFeatures.i);if(void 0!==n){for(var h=0,c=n.length;h<c;h++)d(n[h]).html(t);d(s.nTable).triggerHandler("info.dt")}d("div.dt-info",o.table().container()).each(function(){d(this).html(t),o.trigger("info",[this,t])})}},_macros:function(t,s,o,e,r){var l=this.s.dtApi,i=this.s.dt,a=i.fnFormatNumber;return t.replace(/_START_/g,a.call(i,s)).replace(/_END_/g,a.call(i,o)).replace(/_MAX_/g,a.call(i,e)).replace(/_TOTAL_/g,a.call(i,r)).replace(/_ENTRIES_/g,l.i18n("entries","")).replace(/_ENTRIES-MAX_/g,l.i18n("entries","",e)).replace(/_ENTRIES-TOTAL_/g,l.i18n("entries","",r))},_parseHeight:function(t){var s,o,t=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))(px|em|rem|vh)$/.exec(t);return null!==t&&(o=parseFloat(t[1]),"px"===(t=t[2])?s=o:"vh"===t?s=o/100*d(i).height():"rem"===t?s=o*parseFloat(d(":root").css("font-size")):"em"===t&&(s=o*parseFloat(d("body").css("font-size"))),s)||0},_scroll:function(){var t,s=this,o=this.s.heights,e=this.dom.scroller.scrollTop;this.s.skip||this.s.ingnoreScroll||e!==this.s.lastScrollTop&&(this.s.dt.bFiltered||this.s.dt.bSorted?this.s.lastScrollTop=0:(clearTimeout(this.s.stateTO),this.s.stateTO=setTimeout(function(){s.s.dtApi.state.save()},250),this.s.scrollType=Math.abs(e-this.s.lastScrollTop)>o.viewport?"jump":"cont",this.s.topRowFloat="cont"===this.s.scrollType?this.pixelsToRow(e,!1,!1):this._domain("physicalToVirtual",e)/o.row,this.s.topRowFloat<0&&(this.s.topRowFloat=0),this.s.forceReposition||e<this.s.redrawTop||e>this.s.redrawBottom?(t=Math.ceil((this.s.displayBuffer-1)/2*this.s.viewportRows),t=parseInt(this.s.topRowFloat,10)-t,this.s.forceReposition=!1,t<=0?t=0:t+this.s.dt._iDisplayLength>this.s.dt.fnRecordsDisplay()?(t=this.s.dt.fnRecordsDisplay()-this.s.dt._iDisplayLength)<0&&(t=0):t%2!=0&&t++,(this.s.targetTop=t)!=this.s.dt._iDisplayStart&&(this.s.tableTop=d(this.s.dt.nTable).offset().top,this.s.tableBottom=d(this.s.dt.nTable).height()+this.s.tableTop,t=function(){s.s.dt._iDisplayStart=s.s.targetTop,s.s.dtApi.draw("page")},this.s.dt.oFeatures.bServerSide?(this.s.forceReposition=!0,d(this.s.dt.nTable).triggerHandler("scroller-will-draw.dt"),n.versionCheck("2")?s.s.dtApi.processing(!0):this.s.dt.oApi._fnProcessingDisplay(this.s.dt,!0),clearTimeout(this.s.drawTO),this.s.drawTO=setTimeout(t,this.s.serverWait)):t())):this.s.topRowFloat=this.pixelsToRow(e,!1,!0),this._info(),this.s.lastScrollTop=e,this.s.stateSaveThrottle(),"jump"===this.s.scrollType&&this.s.mousedown&&(this.s.labelVisible=!0),this.s.labelVisible&&(t=(o.viewport-o.labelHeight-o.xbar)/o.scroll,this.dom.label.html(this.s.dt.fnFormatNumber(parseInt(this.s.topRowFloat,10)+1)).css("top",e+e*t).css("display","block"))))},_scrollForce:function(){var t=this.s.heights;t.virtual=t.row*this.s.dt.fnRecordsDisplay(),t.scroll=t.virtual,1e6<t.scroll&&(t.scroll=1e6),this.dom.force.style.height=t.scroll>this.s.heights.row?t.scroll+"px":this.s.heights.row+"px"}}),e.oDefaults=e.defaults={boundaryScale:.5,displayBuffer:9,rowHeight:"auto",serverWait:200},e.version="2.3.0",d(o).on("preInit.dt.dtscroller",function(t,s){var o;"dt"===t.namespace&&(t=s.oInit.scroller,o=n.defaults.scroller,(t||o)&&(o=d.extend({},t,o),!1!==t&&new e(s,o)))}),d.fn.dataTable.Scroller=e,d.fn.DataTable.Scroller=e,d.fn.dataTable.Api);return t.register("scroller()",function(){return this}),t.register("scroller().rowToPixels()",function(t,s,o){var e=this.context;if(e.length&&e[0].oScroller)return e[0].oScroller.rowToPixels(t,s,o)}),t.register("scroller().pixelsToRow()",function(t,s,o){var e=this.context;if(e.length&&e[0].oScroller)return e[0].oScroller.pixelsToRow(t,s,o)}),t.register(["scroller().scrollToRow()","scroller.toPosition()"],function(s,o){return this.iterator("table",function(t){t.oScroller&&t.oScroller.scrollToRow(s,o)}),this}),t.register("row().scrollTo()",function(o){var e=this;return this.iterator("row",function(t,s){t.oScroller&&(s=e.rows({order:"applied",search:"applied"}).indexes().indexOf(s),t.oScroller.scrollToRow(s,o))}),this}),t.register("scroller.measure()",function(s){return this.iterator("table",function(t){t.oScroller&&t.oScroller.measure(s)}),this}),t.register("scroller.page()",function(){var t=this.context;if(t.length&&t[0].oScroller)return t[0].oScroller.pageInfo()}),n}); | ||
!function(o){var e,i;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(t){return o(t,window,document)}):"object"==typeof exports?(e=require("jquery"),i=function(t,s){s.fn.dataTable||require("datatables.net")(t,s)},"undefined"==typeof window?module.exports=function(t,s){return t=t||window,s=s||e(t),i(t,s),o(s,t,t.document)}:(i(window,e),module.exports=o(e,window,window.document))):o(jQuery,window,document)}(function(d,l,o){"use strict";function i(t,s){this instanceof i?(void 0===s&&(s={}),t=d.fn.dataTable.Api(t),this.s={dt:t.settings()[0],dtApi:t,tableTop:0,tableBottom:0,redrawTop:0,redrawBottom:0,autoHeight:!0,viewportRows:0,stateTO:null,stateSaveThrottle:function(){},drawTO:null,heights:{jump:null,page:null,virtual:null,scroll:null,row:null,viewport:null,labelHeight:0,xbar:0},topRowFloat:0,scrollDrawDiff:null,loaderVisible:!1,forceReposition:!1,baseRowTop:0,baseScrollTop:0,mousedown:!1,lastScrollTop:0},this.s=d.extend(this.s,i.oDefaults,s),this.s.heights.row=this.s.rowHeight,this.dom={force:o.createElement("div"),label:d('<div class="dts_label">0</div>'),scroller:null,table:null,loader:null},this.s.dt.oScroller||(this.s.dt.oScroller=this).construct()):alert("Scroller warning: Scroller must be initialised with the 'new' keyword.")}var a=d.fn.dataTable,t=(d.extend(i.prototype,{measure:function(t){this.s.autoHeight&&this._calcRowHeight();var s=this.s.heights,o=(s.row&&(s.viewport=this._parseHeight(d(this.dom.scroller).css("max-height")),this.s.viewportRows=parseInt(s.viewport/s.row,10)+1,this.s.dt._iDisplayLength=this.s.viewportRows*this.s.displayBuffer),this.dom.label.outerHeight());s.xbar=this.dom.scroller.offsetHeight-this.dom.scroller.clientHeight,s.labelHeight=o,void 0!==t&&!t||this.s.dt.oInstance.fnDraw(!1)},pageInfo:function(){var t=this.s.dt,s=this.dom.scroller.scrollTop,t=t.fnRecordsDisplay(),o=Math.ceil(this.pixelsToRow(s+this.s.heights.viewport,!1,this.s.ani));return{start:Math.floor(this.pixelsToRow(s,!1,this.s.ani)),end:t<o?t-1:o-1}},pixelsToRow:function(t,s,o){t-=this.s.baseScrollTop,o=o?(this._domain("physicalToVirtual",this.s.baseScrollTop)+t)/this.s.heights.row:t/this.s.heights.row+this.s.baseRowTop;return s||void 0===s?parseInt(o,10):o},rowToPixels:function(t,s,o){t-=this.s.baseRowTop,o=o?this._domain("virtualToPhysical",this.s.baseScrollTop):this.s.baseScrollTop;return o+=t*this.s.heights.row,s||void 0===s?parseInt(o,10):o},scrollToRow:function(t,s){var o=this,e=!1,i=this.rowToPixels(t),r=t-(this.s.displayBuffer-1)/2*this.s.viewportRows;r<0&&(r=0),void 0===(s=(i>this.s.redrawBottom||i<this.s.redrawTop)&&this.s.dt._iDisplayStart!==r&&(e=!0,i=this._domain("virtualToPhysical",t*this.s.heights.row),this.s.redrawTop<i)&&i<this.s.redrawBottom?!(this.s.forceReposition=!0):s)||s?(this.s.ani=e,d(this.dom.scroller).animate({scrollTop:i},function(){setTimeout(function(){o.s.ani=!1},250)})):d(this.dom.scroller).scrollTop(i)},construct:function(){var e=this,t=this.s.dtApi;if(!this.s.dt.oFeatures.bPaginate)throw new Error("Pagination must be enabled for Scroller to operate");this.dom.force.style.position="relative",this.dom.force.style.top="0px",this.dom.force.style.left="0px",this.dom.force.style.width="1px",this.dom.scroller=t.table().node().parentNode,this.dom.scroller.appendChild(this.dom.force),this.dom.scroller.style.position="relative",this.dom.table=d(">table",this.dom.scroller)[0],this.dom.table.style.position="absolute",this.dom.table.style.top="0px",this.dom.table.style.left="0px",d(t.table().container()).addClass("dts DTS"),this.dom.label.appendTo(this.dom.scroller),this.s.heights.row&&"auto"!=this.s.heights.row&&(this.s.autoHeight=!1),this.s.ingnoreScroll=!0,d(this.dom.scroller).on("scroll.dt-scroller",function(t){e._scroll.call(e)}),d(this.dom.scroller).on("touchstart.dt-scroller",function(){e._scroll.call(e)}),d(this.dom.scroller).on("mousedown.dt-scroller",function(){e.s.mousedown=!0}).on("mouseup.dt-scroller",function(){e.s.labelVisible=!1,e.s.mousedown=!1,e.dom.label.css("display","none")}),d(l).on("resize.dt-scroller",function(){e.measure(!1),e._info()});var i=!0,r=t.state.loaded();t.on("stateSaveParams.scroller",function(t,s,o){i&&r?(o.scroller=r.scroller,i=!1,o.scroller&&(e.s.lastScrollTop=o.scroller.scrollTop)):o.scroller={topRow:e.s.topRowFloat,baseRowTop:e.s.baseRowTop}}),t.on("stateLoadParams.scroller",function(t,s,o){void 0!==o.scroller&&e.scrollToRow(o.scroller.topRow)}),this.measure(!1),r&&r.scroller&&(this.s.topRowFloat=r.scroller.topRow,this.s.baseRowTop=r.scroller.baseRowTop,this.s.baseScrollTop=this.s.baseRowTop*this.s.heights.row,r.scroller.scrollTop=this._domain("physicalToVirtual",this.s.topRowFloat*this.s.heights.row)),e.s.stateSaveThrottle=a.util.throttle(function(){e.s.dtApi.state.save()},500),t.on("init.scroller",function(){e.measure(!1),e.s.scrollType="jump",e._draw(),t.on("draw.scroller",function(){e._draw()})}),t.on("preDraw.dt.scroller",function(){e._scrollForce()}),t.on("destroy.scroller",function(){d(l).off("resize.dt-scroller"),d(e.dom.scroller).off(".dt-scroller"),d(e.s.dt.nTable).off(".scroller"),d(e.s.dt.nTableWrapper).removeClass("DTS"),d("div.DTS_Loading",e.dom.scroller.parentNode).remove(),e.dom.table.style.position="",e.dom.table.style.top="",e.dom.table.style.left=""})},_calcRowHeight:function(){var t=this.s.dt,s=t.nTable,o=s.cloneNode(!1),e=d("<tbody/>").appendTo(o),t=t.oClasses,t=a.versionCheck("2")?{container:t.container,scroller:t.scrolling.container,body:t.scrolling.body}:{container:t.sWrapper,scroller:t.sScrollWrapper,body:t.sScrollBody},i=d('<div class="'+t.container+' DTS"><div class="'+t.scroller+'"><div class="'+t.body+'"></div></div></div>'),r=(d("tbody tr:lt(4)",s).clone().appendTo(e),d("tr",e).length);if(1===r)e.prepend("<tr><td> </td></tr>"),e.append("<tr><td> </td></tr>");else for(;r<3;r++)e.append("<tr><td> </td></tr>");d("div."+t.body,i).append(o);t=this.s.dt.nHolding||s.parentNode;d(t).is(":visible")||(t="body"),i.find("input").removeAttr("name"),i.appendTo(t),this.s.heights.row=d("tr",e).eq(1).outerHeight(),i.remove()},_draw:function(){var t=this,s=this.s.heights,o=this.dom.scroller.scrollTop,e=d(this.s.dt.nTable).height(),i=this.s.dt._iDisplayStart,r=this.s.dt._iDisplayLength,l=this.s.dt.fnRecordsDisplay(),a=o+s.viewport,n=(this.s.skip=!0,!this.s.dt.bSorted&&!this.s.dt.bFiltered||0!==i||this.s.dt._drawHold||(this.s.topRowFloat=0),o="jump"===this.s.scrollType?this._domain("virtualToPhysical",this.s.topRowFloat*s.row):o,this.s.baseScrollTop=o,this.s.baseRowTop=this.s.topRowFloat,o-(this.s.topRowFloat-i)*s.row),i=(0===i?n=0:l<=i+r?n=s.scroll-e:n+e<a&&(this.s.baseScrollTop+=1+((l=a-e)-n),n=l),this.dom.table.style.top=n+"px",this.s.tableTop=n,this.s.tableBottom=e+this.s.tableTop,(o-this.s.tableTop)*this.s.boundaryScale);this.s.redrawTop=o-i,this.s.redrawBottom=o+i>s.scroll-s.viewport-s.row?s.scroll-s.viewport-s.row:o+i,this.s.skip=!1,t.s.ingnoreScroll&&(this.s.dt.oFeatures.bStateSave&&null!==this.s.dt.oLoadedState&&void 0!==this.s.dt.oLoadedState.scroller?((r=!(!this.s.dt.sAjaxSource&&!t.s.dt.ajax||this.s.dt.oFeatures.bServerSide))&&2<=this.s.dt.iDraw||!r&&1<=this.s.dt.iDraw)&&setTimeout(function(){d(t.dom.scroller).scrollTop(t.s.dt.oLoadedState.scroller.scrollTop),setTimeout(function(){t.s.ingnoreScroll=!1},0)},0):t.s.ingnoreScroll=!1),this.s.dt.oFeatures.bInfo&&setTimeout(function(){t._info.call(t)},0),d(this.s.dt.nTable).triggerHandler("position.dts.dt",n)},_domain:function(t,s){var o,e=this.s.heights,i=1e4;return e.virtual===e.scroll||s<i?s:"virtualToPhysical"===t&&s>=e.virtual-i?(o=e.virtual-s,e.scroll-o):"physicalToVirtual"===t&&s>=e.scroll-i?(o=e.scroll-s,e.virtual-o):(e=i-(o=(e.virtual-i-i)/(e.scroll-i-i))*i,"virtualToPhysical"===t?(s-e)/o:o*s+e)},_info:function(){if(this.s.dt.oFeatures.bInfo){var t=this.s.dt,s=this.s.dtApi,o=t.oLanguage,e=s.page.info(),i=e.recordsDisplay,e=e.recordsTotal,r=(this.s.lastScrollTop-this.s.baseScrollTop)/this.s.heights.row,r=Math.floor(this.s.baseRowTop+r),l=(r="jump"===this.s.scrollType?Math.floor(this.s.topRowFloat)+1:r)+Math.floor(this.s.heights.viewport/this.s.heights.row),l=i<l?i:l,a=0===i&&i==e?o.sInfoEmpty+o.sInfoPostFix:0===i?o.sInfoEmpty+" "+o.sInfoFiltered+o.sInfoPostFix:i==e?o.sInfo+o.sInfoPostFix:o.sInfo+" "+o.sInfoFiltered+o.sInfoPostFix,o=(a=this._macros(a,r,l,e,i),o.fnInfoCallback),n=(o&&(a=o.call(t.oInstance,t,r,l,e,i,a)),t.aanFeatures.i);if(void 0!==n){for(var h=0,c=n.length;h<c;h++)d(n[h]).html(a);d(t.nTable).triggerHandler("info.dt")}d("div.dt-info",s.table().container()).each(function(){d(this).html(a),s.trigger("info",[s.settings()[0],this,a])})}},_macros:function(t,s,o,e,i){var r=this.s.dtApi,l=this.s.dt,a=l.fnFormatNumber;return t.replace(/_START_/g,a.call(l,s)).replace(/_END_/g,a.call(l,o)).replace(/_MAX_/g,a.call(l,e)).replace(/_TOTAL_/g,a.call(l,i)).replace(/_ENTRIES_/g,r.i18n("entries","")).replace(/_ENTRIES-MAX_/g,r.i18n("entries","",e)).replace(/_ENTRIES-TOTAL_/g,r.i18n("entries","",i))},_parseHeight:function(t){var s,o,t=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))(px|em|rem|vh)$/.exec(t);return null!==t&&(o=parseFloat(t[1]),"px"===(t=t[2])?s=o:"vh"===t?s=o/100*d(l).height():"rem"===t?s=o*parseFloat(d(":root").css("font-size")):"em"===t&&(s=o*parseFloat(d("body").css("font-size"))),s)||0},_scroll:function(){var t,s=this,o=this.s.heights,e=this.dom.scroller.scrollTop;this.s.skip||this.s.ingnoreScroll||e!==this.s.lastScrollTop&&(this.s.dt.bFiltered||this.s.dt.bSorted?this.s.lastScrollTop=0:(clearTimeout(this.s.stateTO),this.s.stateTO=setTimeout(function(){s.s.dtApi.state.save()},250),this.s.scrollType=Math.abs(e-this.s.lastScrollTop)>o.viewport?"jump":"cont",this.s.topRowFloat="cont"===this.s.scrollType?this.pixelsToRow(e,!1,!1):this._domain("physicalToVirtual",e)/o.row,this.s.topRowFloat<0&&(this.s.topRowFloat=0),this.s.forceReposition||e<this.s.redrawTop||e>this.s.redrawBottom?(t=Math.ceil((this.s.displayBuffer-1)/2*this.s.viewportRows),t=parseInt(this.s.topRowFloat,10)-t,this.s.forceReposition=!1,t<=0?t=0:t+this.s.dt._iDisplayLength>this.s.dt.fnRecordsDisplay()?(t=this.s.dt.fnRecordsDisplay()-this.s.dt._iDisplayLength)<0&&(t=0):t%2!=0&&t++,(this.s.targetTop=t)!=this.s.dt._iDisplayStart&&(this.s.tableTop=d(this.s.dt.nTable).offset().top,this.s.tableBottom=d(this.s.dt.nTable).height()+this.s.tableTop,t=function(){s.s.dt._iDisplayStart=s.s.targetTop,s.s.dtApi.draw("page")},this.s.dt.oFeatures.bServerSide?(this.s.forceReposition=!0,d(this.s.dt.nTable).triggerHandler("scroller-will-draw.dt"),a.versionCheck("2")?s.s.dtApi.processing(!0):this.s.dt.oApi._fnProcessingDisplay(this.s.dt,!0),clearTimeout(this.s.drawTO),this.s.drawTO=setTimeout(t,this.s.serverWait)):t())):this.s.topRowFloat=this.pixelsToRow(e,!1,!0),this._info(),this.s.lastScrollTop=e,this.s.stateSaveThrottle(),"jump"===this.s.scrollType&&this.s.mousedown&&(this.s.labelVisible=!0),this.s.labelVisible&&(t=(o.viewport-o.labelHeight-o.xbar)/o.scroll,this.dom.label.html(this.s.dt.fnFormatNumber(parseInt(this.s.topRowFloat,10)+1)).css("top",e+e*t).css("display","block"))))},_scrollForce:function(){var t=this.s.heights;t.virtual=t.row*this.s.dt.fnRecordsDisplay(),t.scroll=t.virtual,1e6<t.scroll&&(t.scroll=1e6),this.dom.force.style.height=t.scroll>this.s.heights.row?t.scroll+"px":this.s.heights.row+"px"}}),i.oDefaults=i.defaults={boundaryScale:.5,displayBuffer:9,rowHeight:"auto",serverWait:200},i.version="2.4.0",d(o).on("preInit.dt.dtscroller",function(t,s){var o,e;"dt"===t.namespace&&(t=s.oInit.scroller,o=a.defaults.scroller,t||o)&&(e=d.extend({},t,o),!1!==t)&&new i(s,e)}),d.fn.dataTable.Scroller=i,d.fn.DataTable.Scroller=i,d.fn.dataTable.Api);return t.register("scroller()",function(){return this}),t.register("scroller().rowToPixels()",function(t,s,o){var e=this.context;if(e.length&&e[0].oScroller)return e[0].oScroller.rowToPixels(t,s,o)}),t.register("scroller().pixelsToRow()",function(t,s,o){var e=this.context;if(e.length&&e[0].oScroller)return e[0].oScroller.pixelsToRow(t,s,o)}),t.register(["scroller().scrollToRow()","scroller.toPosition()"],function(s,o){return this.iterator("table",function(t){t.oScroller&&t.oScroller.scrollToRow(s,o)}),this}),t.register("row().scrollTo()",function(o){var e=this;return this.iterator("row",function(t,s){t.oScroller&&(s=e.rows({order:"applied",search:"applied"}).indexes().indexOf(s),t.oScroller.scrollToRow(s,o))}),this}),t.register("scroller.measure()",function(s){return this.iterator("table",function(t){t.oScroller&&t.oScroller.measure(s)}),this}),t.register("scroller.page()",function(){var t=this.context;if(t.length&&t[0].oScroller)return t[0].oScroller.pageInfo()}),a}); |
@@ -7,3 +7,3 @@ { | ||
"types": "./types/types.d.ts", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"files": [ | ||
@@ -24,3 +24,3 @@ "js/**/*.js", | ||
"dependencies": { | ||
"datatables.net": ">=1.11", | ||
"datatables.net": ">=1.11.0", | ||
"jquery": ">=1.7" | ||
@@ -27,0 +27,0 @@ }, |
@@ -47,3 +47,3 @@ // Type definitions for DataTables Scroller | ||
*/ | ||
new (dt: Api<any>, settings: boolean | ConfigScroller): void; | ||
new (dt: Api<any>, settings: boolean | ConfigScroller): DataTablesStatic['Scroller']; | ||
@@ -50,0 +50,0 @@ /** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
113122
2502
Updateddatatables.net@>=1.11.0