From 12770c50a21c55cbaa55956ac26a052c255c8cb4 Mon Sep 17 00:00:00 2001 From: Os1r1s110 Date: Mon, 24 Feb 2020 15:46:31 -0500 Subject: [PATCH 1/2] add a `displayLabel` option let the user decide if he wants a label displayed when user is scrolling using the scrollbar or not --- js/dataTables.scroller.js | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/js/dataTables.scroller.js b/js/dataTables.scroller.js index 9d8a504..d23450b 100644 --- a/js/dataTables.scroller.js +++ b/js/dataTables.scroller.js @@ -299,8 +299,11 @@ $.extend( Scroller.prototype, { this.s.dt._iDisplayLength = this.s.viewportRows * this.s.displayBuffer; } - var label = this.dom.label.outerHeight(); - heights.labelFactor = (heights.viewport-label) / heights.scroll; + if(this.s.displayLabel) + { + var label = this.dom.label.outerHeight(); + heights.labelFactor = (heights.viewport-label) / heights.scroll; + } if ( redraw === undefined || redraw ) { @@ -490,7 +493,10 @@ $.extend( Scroller.prototype, { .append( this.dom.loader ); } - this.dom.label.appendTo(this.dom.scroller); + if(this.s.displayLabel) + { + this.dom.label.appendTo(this.dom.scroller); + } /* Initial size calculations */ if ( this.s.heights.row && this.s.heights.row != 'auto' ) @@ -521,10 +527,13 @@ $.extend( Scroller.prototype, { that.s.mousedown = true; }) .on('mouseup.dt-scroller', function () { - that.s.labelVisible = false; - that.s.mousedown = false; - that.dom.label.css('display', 'none'); - }); + that.s.mousedown = false; + if (this.s.displayLabel) + { + that.s.labelVisible = false; + that.dom.label.css('display', 'none'); + } + }); // On resize, update the information element, since the number of rows shown might change $(window).on( 'resize.dt-scroller', function () { @@ -1063,7 +1072,7 @@ $.extend( Scroller.prototype, { this.s.lastScrollTop = iScrollTop; this.s.stateSaveThrottle(); - if ( this.s.scrollType === 'jump' && this.s.mousedown ) { + if ( this.s.scrollType === 'jump' && this.s.mousedown && this.s.displayLabel) { this.s.labelVisible = true; } if (this.s.labelVisible) { @@ -1174,7 +1183,16 @@ Scroller.defaults = { * @default 200 * @static */ - serverWait: 200 + serverWait: 200, + + /** + * While scrolling using the scrollbar, a label is displayed to indicate the user + * the approximate position displayed within the whole table content + * @type bool + * @default true + * @static + */ + displayLabel: true }; Scroller.oDefaults = Scroller.defaults; From 8a2283f88f8a96f9d93ed42e38bacd5552b66025 Mon Sep 17 00:00:00 2001 From: Os1r1s110 Date: Mon, 24 Feb 2020 15:47:43 -0500 Subject: [PATCH 2/2] add documentation for the new option --- docs/option/scroller.displayLabel.xml | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 docs/option/scroller.displayLabel.xml diff --git a/docs/option/scroller.displayLabel.xml b/docs/option/scroller.displayLabel.xml new file mode 100644 index 0000000..5d9f605 --- /dev/null +++ b/docs/option/scroller.displayLabel.xml @@ -0,0 +1,32 @@ + + + scroller.displayLabel + Display a label while user is scrolling with the scrollbar + + + + * `true` show the label when scrolling + * `false` do not show + + + + + Label is displayed when scrolling using the scrollbar + + + + While scrolling using the scrollbar, a label is displayed to indicate the user the approximate position displayed within the whole dataset + + + + +