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
1 change: 1 addition & 0 deletions docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ tableDragger(document.querySelector('#row-table'), { mode: 'row' });
tableDragger(document.querySelector('#only-body-table'), { mode: 'row', onlyBody: true });
tableDragger(document.querySelector('#handle-table'), { dragHandler: '.handle' });
tableDragger(document.querySelector('#free-table'), { mode: 'free', dragHandler: '.handle', onlyBody: true });
tableDragger(document.querySelector('#free-table-first-fixed'), { mode: 'free', dragHandler: '.handle', onlyBody: true, fixFirstColumn: true });
tableDragger(document.querySelector('#event-table'), { mode: 'free', dragHandler: '.handle', onlyBody: true })
.on('drag', () => {
console.log('drag');
Expand Down
38 changes: 38 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,44 @@ <h4>Free <span class="small">After mousedown, move mouse horizontally or vertica
</pre>
</section>

<section>
<h4>Free with the first column fixed <span class="small">After mousedown, move mouse horizontally or vertically, see what happens. Don't forget to specify drag handler</span>
</h4>
<table id="free-table-first-fixed" class="sindu-table">
<thead>
<tr>
<th>Movie Title</th>
<th>Genre</th>
<th>Year</th>
<th>Gross</th>
</tr>
</thead>
<tr>
<td>Star Wars</td>
<td>Adventure, Sci-fi <i class="handle">dragme</i></td>
<td>1977</td>
<td>$460,935,665</td>
</tr>
<tr>
<td>Howard The Duck</td>
<td>"Comedy"</td>
<td>1986</td>
<td>$16,295,774</td>
</tr>
<tr>
<td>American Graffiti</td>
<td>Comedy, Drama</td>
<td>1973</td>
<td>$115,000,000</td>
</tr>
</table>
<pre>
<code class="language-javascript">
tableDragger(document.querySelector(&#x22#row-table&#x22), { mode: &#x22row&#x22, onlyBody: true, dragHandler: &#x22.handle&#x22, fixFirstColumn: true });
</code>
</pre>
</section>

<section>
<h4>Only Body <span class="small">Setting onlyBody to true in row mode, user can only lift rows in tBody</span>
</h4>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"karma-jasmine": "^1.0.2",
"karma-mocha": "^1.2.0",
"karma-phantomjs-launcher": "^1.0.0",
"karma-sinon-chai": "^1.2.0",
"karma-sinon-chai": "1.2.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "0.0.26",
"karma-webpack": "^1.7.0",
Expand All @@ -96,7 +96,7 @@
"semver": "^5.3.0",
"shelljs": "^0.7.4",
"sinon": "^1.17.3",
"sinon-chai": "^2.8.0",
"sinon-chai": "2.8.0",
"webpack": "^1.13.2",
"webpack-dev-middleware": "^1.8.3",
"webpack-hot-middleware": "^2.12.2",
Expand Down
6 changes: 5 additions & 1 deletion src/draggable-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,20 @@ export default class Dragger {
const s = window.getComputedStyle(originEl).getPropertyValue('border-spacing').split(' ')[0];
const attr = mode === 'column' ? 'margin-right' : 'margin-bottom';
const l = el.children.length;
let i = 0;
Array.from(el.children).forEach((li, dex) => {
/* eslint-disable no-param-reassign*/
const table = li && li.querySelector('table');
if (this.options.onlyBody && mode === 'row' && !Array.from(table.children).some(o => o.nodeName === 'TBODY')) {
if ((this.options.onlyBody && mode === 'row' && !Array.from(table.children).some(o => o.nodeName === 'TBODY')) ||
(this.options.onlyBody && this.options.fixFirstColumn && mode === 'column' && i === 0)) {
li.classList.add(classes.static);
}

if (s && dex < (l - 1)) {
li.style[attr] = `-${s}`;
}

i += 1;
});

el.parentElement.classList.add(classes.dragging);
Expand Down