From 97d38acb6f7d234d953660e478864f55e2be5cc0 Mon Sep 17 00:00:00 2001 From: sp-kilobug Date: Mon, 20 Jul 2015 20:59:26 +0200 Subject: [PATCH] fix flex containers in row mode fix http://jsbin.com/cuduyo/edit?html,css,output compatible with flex-direction: row flex-direction: row-reverse https://developer.mozilla.org/fr/docs/Web/CSS/flex-direction --- Sortable.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sortable.js b/Sortable.js index 482b295..0c05729 100644 --- a/Sortable.js +++ b/Sortable.js @@ -36,6 +36,7 @@ lastEl, lastCSS, + lastParentCSS, oldIndex, newIndex, @@ -611,13 +612,15 @@ if (lastEl !== target) { lastEl = target; lastCSS = _css(target); + lastParentCSS = _css(target.parentNode); } var targetRect = target.getBoundingClientRect(), width = targetRect.right - targetRect.left, height = targetRect.bottom - targetRect.top, - floating = /left|right|inline/.test(lastCSS.cssFloat + lastCSS.display), + floating = /left|right|inline/.test(lastCSS.cssFloat + lastCSS.display) + || (lastParentCSS.display == 'flex' && lastParentCSS['flex-direction'].indexOf('row') === 0), isWide = (target.offsetWidth > dragEl.offsetWidth), isLong = (target.offsetHeight > dragEl.offsetHeight), halfway = (floating ? (evt.clientX - targetRect.left) / width : (evt.clientY - targetRect.top) / height) > 0.5, @@ -760,7 +763,7 @@ this.save(); } } - + // Nulling rootEl = dragEl = @@ -1185,7 +1188,7 @@ Sortable.create = function (el, options) { return new Sortable(el, options); }; - + // Export Sortable.version = '1.2.2';