Skip to content

Commit

Permalink
jump scroller
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreardon committed May 20, 2018
1 parent 9daafd1 commit 311f1cb
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 229 deletions.
5 changes: 3 additions & 2 deletions src/state/auto-scroller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { type Position } from 'css-box-model';
import createFluidScroller, { type FluidScroller } from './fluid-scroller';
import createJumpScroller, { type JumpScroller } from './jump-scroller';
import type { AutoScroller } from './auto-scroller-types';
import { move as moveAction, updateDroppableScroll } from '../action-creators';
import type { DroppableId } from '../../types';
import { move as moveAction } from '../action-creators';

type Args = {|
scrollDroppable: typeof updateDroppableScroll,
scrollDroppable: (id: DroppableId, change: Position) => void,
move: typeof moveAction,
scrollWindow: (offset: Position) => void,
|}
Expand Down
15 changes: 5 additions & 10 deletions src/state/auto-scroller/jump-scroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ import {
getWindowOverlap,
getDroppableOverlap,
} from './can-scroll';
import { move as moveAction, updateDroppableScroll as updateDroppableScrollAction } from '../action-creators';
import { move as moveAction } from '../action-creators';
import type {
DroppableDimension,
DraggableLocation,
Viewport,
DraggingState,
DroppableId,
} from '../../types';

type Args = {|
scrollDroppable: typeof updateDroppableScrollAction,
scrollDroppable: (id: DroppableId, change: Position) => void,
scrollWindow: (offset: Position) => void,
move: typeof moveAction,
|}
Expand Down Expand Up @@ -48,19 +49,13 @@ export default ({

// Droppable can absorb the entire change
if (!overlap) {
scrollDroppable({
id: droppable.descriptor.id,
offset: change,
});
scrollDroppable(droppable.descriptor.id, change);
return null;
}

// Droppable can only absorb a part of the change
const whatTheDroppableCanScroll: Position = subtract(change, overlap);
scrollDroppable({
id: droppable.descriptor.id,
offset: whatTheDroppableCanScroll,
});
scrollDroppable(droppable.descriptor.id, whatTheDroppableCanScroll);

const remainder: Position = subtract(change, whatTheDroppableCanScroll);
return remainder;
Expand Down
2 changes: 1 addition & 1 deletion src/state/middleware/auto-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ export default (getMarshal: () => DimensionMarshal) =>

scroller.jumpScroll(state);
};
};
};
Loading

0 comments on commit 311f1cb

Please sign in to comment.