Skip to content

Commit 35996f5

Browse files
author
Clauderic Demers
committed
chore: clean up inconsistencies in stories
1 parent db3bd3b commit 35996f5

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

src/.stories/index.js

+23-25
Original file line numberDiff line numberDiff line change
@@ -180,20 +180,20 @@ class ListWrapper extends Component {
180180
height: 600,
181181
};
182182

183-
onSortStart = (event) => {
183+
onSortStart = (sortEvent, nativeEvent) => {
184184
const {onSortStart} = this.props;
185185
this.setState({isSorting: true});
186186

187187
document.body.style.cursor = 'grabbing';
188188

189189
if (onSortStart) {
190-
onSortStart(event, this.refs.component);
190+
onSortStart(sortEvent, nativeEvent, this.refs.component);
191191
}
192192
};
193193

194-
onSortEnd = (event) => {
194+
onSortEnd = (sortEvent, nativeEvent) => {
195195
const {onSortEnd} = this.props;
196-
const {oldIndex, newIndex} = event;
196+
const {oldIndex, newIndex} = sortEvent;
197197
const {items} = this.state;
198198

199199
this.setState({
@@ -204,7 +204,7 @@ class ListWrapper extends Component {
204204
document.body.style.cursor = '';
205205

206206
if (onSortEnd) {
207-
onSortEnd(event, this.refs.component);
207+
onSortEnd(sortEvent, nativeEvent, this.refs.component);
208208
}
209209
};
210210

@@ -534,11 +534,6 @@ storiesOf('General | Layout / Grid', module)
534534
);
535535
})
536536
.add('Large first item', () => {
537-
const transformOrigin = {
538-
x: 0,
539-
y: 0,
540-
};
541-
542537
return (
543538
<div className={style.root}>
544539
<ListWrapper
@@ -557,17 +552,21 @@ storiesOf('General | Layout / Grid', module)
557552
style.gridItem,
558553
style.gridItemVariableSized,
559554
)}
560-
onSortStart={({node}, event) => {
561-
const boundingClientRect = node.getBoundingClientRect();
562-
563-
transformOrigin.x =
564-
((event.clientX - boundingClientRect.left) /
565-
boundingClientRect.width) *
566-
100;
567-
transformOrigin.y =
568-
((event.clientY - boundingClientRect.top) /
569-
boundingClientRect.height) *
570-
100;
555+
onSortStart={({node, helper}, event) => {
556+
const nodeBoundingClientRect = node.getBoundingClientRect();
557+
const helperWrapperNode = helper.childNodes[0];
558+
const transformOrigin = {
559+
x:
560+
((event.clientX - nodeBoundingClientRect.left) /
561+
nodeBoundingClientRect.width) *
562+
100,
563+
y:
564+
((event.clientY - nodeBoundingClientRect.top) /
565+
nodeBoundingClientRect.height) *
566+
100,
567+
};
568+
569+
helperWrapperNode.style.transformOrigin = `${transformOrigin.x}% ${transformOrigin.y}%`;
571570
}}
572571
onSortOver={({nodes, newIndex, index, helper}) => {
573572
const finalNodes = arrayMove(nodes, index, newIndex);
@@ -577,7 +576,6 @@ storiesOf('General | Layout / Grid', module)
577576
const helperWrapperNode = helper.childNodes[0];
578577

579578
helperWrapperNode.style.transform = `scale(${helperScale})`;
580-
helperWrapperNode.style.transformOrigin = `${transformOrigin.x}% ${transformOrigin.y}%`;
581579

582580
finalNodes.forEach(({node}, i) => {
583581
const oldNode = nodes[i].node;
@@ -763,7 +761,7 @@ storiesOf('Advanced examples | Virtualization libraries / react-window', module)
763761
items={getItems(500, 59)}
764762
itemHeight={59}
765763
helperClass={style.stylizedHelper}
766-
onSortEnd={(_, ref) => {
764+
onSortEnd={(_sortEvent, _nativeEvent, ref) => {
767765
// We need to inform React Window that the order of the items has changed
768766
const instance = ref.getWrappedInstance();
769767
const list = instance.refs.VirtualList;
@@ -781,7 +779,7 @@ storiesOf('Advanced examples | Virtualization libraries / react-window', module)
781779
component={SortableReactWindow(VariableSizeList)}
782780
items={getItems(500)}
783781
helperClass={style.stylizedHelper}
784-
onSortEnd={(_, ref) => {
782+
onSortEnd={(_sortEvent, _nativeEvent, ref) => {
785783
// We need to inform React Window that the item heights have changed
786784
const instance = ref.getWrappedInstance();
787785
const list = instance.refs.VirtualList;
@@ -817,7 +815,7 @@ storiesOf(
817815
items={getItems(500)}
818816
itemHeight={89}
819817
helperClass={style.stylizedHelper}
820-
onSortEnd={(_, ref) => {
818+
onSortEnd={(_sortEvent, _nativeEvent, ref) => {
821819
// We need to inform React Virtualized that the item heights have changed
822820
const instance = ref.getWrappedInstance();
823821
const list = instance.refs.VirtualList;

0 commit comments

Comments
 (0)