Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions docs/option/scroller.displayLabel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dt-option library="Scroller">
<name>scroller.displayLabel</name>
<summary>Display a label while user is scrolling with the scrollbar</summary>

<type type="boolean">
<description>
* `true` show the label when scrolling
* `false` do not show
</description>
</type>

<default value="true">
Label is displayed when scrolling using the scrollbar
</default>

<description>
While scrolling using the scrollbar, a label is displayed to indicate the user the approximate position displayed within the whole dataset
</description>

<example title="Do not display label when scrolling using scrollbar"><![CDATA[

$('#example').DataTable( {
scrollY: true,
scroller: {
displayLabel: false
}
} );

]]></example>

</dt-option>
36 changes: 27 additions & 9 deletions js/dataTables.scroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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' )
Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down