diff --git a/docs/index.js b/docs/index.js
index 565dfb1..cba2e32 100644
--- a/docs/index.js
+++ b/docs/index.js
@@ -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');
diff --git a/index.html b/index.html
index fe005d5..b8bbd62 100644
--- a/index.html
+++ b/index.html
@@ -259,6 +259,44 @@
Free After mousedown, move mouse horizontally or vertica
+
+ Free with the first column fixed After mousedown, move mouse horizontally or vertically, see what happens. Don't forget to specify drag handler
+
+
+
+
+ | Movie Title |
+ Genre |
+ Year |
+ Gross |
+
+
+
+ | Star Wars |
+ Adventure, Sci-fi dragme |
+ 1977 |
+ $460,935,665 |
+
+
+ | Howard The Duck |
+ "Comedy" |
+ 1986 |
+ $16,295,774 |
+
+
+ | American Graffiti |
+ Comedy, Drama |
+ 1973 |
+ $115,000,000 |
+
+
+
+
+tableDragger(document.querySelector("#row-table"), { mode: "row", onlyBody: true, dragHandler: ".handle", fixFirstColumn: true });
+
+
+
+
Only Body Setting onlyBody to true in row mode, user can only lift rows in tBody
diff --git a/package.json b/package.json
index 7fee1e9..01dc0fc 100644
--- a/package.json
+++ b/package.json
@@ -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",
@@ -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",
diff --git a/src/draggable-list.js b/src/draggable-list.js
index 7fcfbcc..f80c4c8 100644
--- a/src/draggable-list.js
+++ b/src/draggable-list.js
@@ -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);