diff --git a/src/.stories/Storybook.scss b/src/.stories/Storybook.scss index 9c62f41bd..2f2e2a48d 100644 --- a/src/.stories/Storybook.scss +++ b/src/.stories/Storybook.scss @@ -11,6 +11,10 @@ $focusedOutlineColor: #4c9ffe; align-items: center; } +.rootAutoHeight { + height: auto; +} + // Base styles .list { width: 400px; @@ -122,6 +126,10 @@ $focusedOutlineColor: #4c9ffe; background-color: transparent; } +.gridAutoHeight { + height: auto; +} + .gridItem { width: 130px; height: 130px; diff --git a/src/.stories/index.js b/src/.stories/index.js index 5981f3cb9..dfc5bae66 100644 --- a/src/.stories/index.js +++ b/src/.stories/index.js @@ -438,22 +438,20 @@ const ShrinkingSortableList = SortableContainer( }, ); -const NestedSortableList = SortableContainer( - ({className, items, isSorting}) => { - return ( -
- {items.map((value, index) => ( - - ))} -
- ); - }, -); +const NestedSortableList = SortableContainer(({className, items}) => { + return ( +
+ {items.map((value, index) => ( + + ))} +
+ ); +}); storiesOf('General | Layout / Vertical list', module) .add('Basic setup', () => { @@ -515,11 +513,6 @@ storiesOf('General | Layout / Horizontal list', module).add( storiesOf('General | Layout / Grid', module) .add('Basic setup', () => { - const transformOrigin = { - x: 0, - y: 0, - }; - return (
); + }) + .add('Window as scroll container', () => { + return ( +
+ +
+ ); }); storiesOf('General | Configuration / Options', module) diff --git a/src/SortableContainer/index.js b/src/SortableContainer/index.js index 9b24a0456..72bc57a77 100644 --- a/src/SortableContainer/index.js +++ b/src/SortableContainer/index.js @@ -260,6 +260,12 @@ export default function sortableContainer( const margin = getElementMargin(node); const gridGap = getContainerGridGap(this.container); const containerBoundingRect = this.scrollContainer.getBoundingClientRect(); + + // Need for correct sorting behavior in grid layout with enabled `useWindowAsScrollContainer` + if (useWindowAsScrollContainer) { + containerBoundingRect.width = this.container.clientWidth; + } + const dimensions = getHelperDimensions({index, node, collection}); this.node = node; @@ -645,9 +651,9 @@ export default function sortableContainer( // For keyboard sorting, we want user input to dictate the position of the nodes const mustShiftBackward = - isKeySorting && (index > this.index && index <= prevIndex); + isKeySorting && index > this.index && index <= prevIndex; const mustShiftForward = - isKeySorting && (index < this.index && index >= prevIndex); + isKeySorting && index < this.index && index >= prevIndex; const translate = { x: 0,