0
我有一個針對表的JQuery UI Sortable。在Firefox中,當你點擊並拖動一行到最底層的Chrome瀏覽器時,會爲你滾動列表,但是在Firefox中,它只是將屏幕拖動到最後一個可見行下方的空白處。當在Firefox中列表的底部時,JQuery UI排序不會滾動
這個特定的表格是在一個具有固定高度的div內。
我使用的是JQuery 2.1.0和JQuery UI 1.12。
下面是一個代碼筆: - https://codepen.io/anon/pen/BWVpdE
下面是HTML: -
<div class="scrollableContainer">
<table>
<thead>
<tr class="ui-state-default">
<th colspan="4">Original</th>
<th colspan="4">table heading</th>
<th colspan="4">table heading</th>
<th colspan="4">table heading</th>
<th colspan="4">table heading</th>
<th colspan="4">Current Pos</th>
</tr>
</thead>
<tfoot>
<tr class="ui-state-default">
<th colspan="4">Original</th>
<th colspan="4">table footer</th>
<th colspan="4">table footer</th>
<th colspan="4">table footer</th>
<th colspan="4">table footer</th>
<th colspan="4">Current Pos</th>
</tr>
</tfoot>
<tbody>
<tr class="ui-state-default">
<th colspan="4">First Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">1</td>
</tr>
<tr class="ui-state-default even">
<th colspan="4">Second Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">2</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Third Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">3</td>
</tr>
<tr class="ui-state-default even">
<th colspan="4">Fourth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">4</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
<tr class="ui-state-default">
<th colspan="4">Fifth Row</th>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">data</td>
<td colspan="4">5</td>
</tr>
</tbody>
</table>
</div>
這裏是SCSS: -
.scrollableContainer {
padding-top:60px;
height: 200px;
position:relative;
}
.scrollArea {
height:100%;
overflow-x:hidden;
overflow-y:auto;
}
table {
border-collapse: collapse;
overflow-x: hidden;
overflow-y: auto;
}
td, th {
background: #fff;
border-width: 0;
border-bottom: 1px solid #B8B8B8;
font-weight: normal !important;
padding: 15px;
text-align: left;
vertical-align: middle;
}
tr.even {
td, th {
background: #f1f1f1;
}
}
thead, tfoot {
text-transform: uppercase;
th {
background: #ccc;
}
}
body {
color: #111;
font-size: 16px;
font-family: sans-serif;
}
這裏是JS: -
$("table tbody").sortable({
update: function(event, ui) {
$(this).children().each(function(index) {
$(this).find('td').last().html(index + 1)
});
}
});