1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-12-12 00:08:48 +01:00
DataTables/media/unit_testing/tests_onhold/1_dom/sScrollXY.js
Allan Jardine ab9dfd5052 Fix: x-scrolling to the end of a table would cause the header and the columns to go out of alignment due to the header not being able to scroll as far as was needed (this was caused by the changes in 876a75f) - 8332.
Fix: Table could conitnually expand when x-scrolling was enabled. This was partly addressed in 6776, but the fix was incomplete as it would still occur on Safari Mac (possibly other browsers as well). This fix is very closely related to 8332 (hence commiting together as they are interdependent). Now use padding right on the header/footer wrapper to provide the overflow scroll ability, but only add it when a scrollbar is present - otherwise the width gets added on and we get the forever expanding table.
Dev: Unit tests - New tests for scrolling to ensure 6776 and 8332 don't occur again
2012-02-06 18:09:16 +00:00

63 lines
1.7 KiB
JavaScript
Executable File

// DATA_TEMPLATE: dom_data
oTest.fnStart( "sScrollX / Y" );
$(document).ready( function () {
// Force some x scrolling
$('body').css('white-space', 'nowrap');
$('#container').css('width', '400px');
var oTable = $('#example').dataTable( {
"sScrollX": "100%",
"sScrollY": "200px",
"bPaginate": false
} );
oTest.fnWaitTest(
"Header follows x-scrolling",
function () { $('div.dataTables_scrollBody').scrollLeft(20); },
function () { return $('div.dataTables_scrollHead').scrollLeft() == 20; }
);
oTest.fnWaitTest(
"Footer follows x-scrolling",
null,
function () { return $('div.dataTables_scrollFoot').scrollLeft() == 20; }
);
oTest.fnWaitTest(
"y-scrolling has no effect on header",
function () { $('div.dataTables_scrollBody').scrollTop(20); },
function () { return $('div.dataTables_scrollHead').scrollLeft() == 20; }
);
oTest.fnWaitTest(
"Filtering results in sets y-scroll back to 0",
function () { oTable.fnFilter('1') },
function () { return $('div.dataTables_scrollBody').scrollTop() == 0; }
);
oTest.fnWaitTest(
"Filtering has no effect on x-scroll",
null,
function () { return $('div.dataTables_scrollBody').scrollLeft() == 20; }
);
oTest.fnWaitTest(
"Full x-scroll has header track all the way with it",
function () {
$('div.dataTables_scrollBody').scrollLeft(
$('#example').width() - $('div.dataTables_scrollBody')[0].clientWidth
);
},
function () { return $('div.dataTables_scrollBody').scrollLeft() == $('div.dataTables_scrollHead').scrollLeft(); }
);
oTest.fnTest(
"Footer also tracked all the way",
null,
function () { return $('div.dataTables_scrollBody').scrollLeft() == $('div.dataTables_scrollFoot').scrollLeft(); }
);
oTest.fnComplete();
} );