Skip to content

Commit

Permalink
drastically improved viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreardon committed May 21, 2018
1 parent f5df39a commit edc21bb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
14 changes: 6 additions & 8 deletions src/state/middleware/auto-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ export default (getMarshal: () => DimensionMarshal) =>
scrollWindow,
});

return (action: Action): mixed => {
const shouldCancel = (action: Action) =>
// Need to cancel any pending auto scrolling when drag is ending
if (isDragEnding(action)) {
scroller.cancel();
next(action);
return;
}

isDragEnding(action) ||
// A new bulk collection is starting - cancel any pending auto scrolls
if (action.type === 'BULK_COLLECTION_STARTING') {
action.type === 'BULK_COLLECTION_STARTING';

return (action: Action): mixed => {
if (shouldCancel(action)) {
scroller.cancel();
next(action);
return;
Expand Down
2 changes: 0 additions & 2 deletions src/state/move-to-next-index/in-home-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ export default ({
const distance: Position = subtract(newPageBorderBoxCenter, previousPageBorderBoxCenter);
const distanceWithScroll: Position = withDroppableDisplacement(droppable, distance);

console.log('request jump scroll', distanceWithScroll);

return {
pageBorderBoxCenter: previousPageBorderBoxCenter,
impact: newImpact,
Expand Down
11 changes: 6 additions & 5 deletions src/state/scroll-viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { getRect, type Rect } from 'css-box-model';
import type { Position } from 'css-box-model';
import { subtract, negate } from './position';
import { offsetByPosition } from './spacing';
import type { Viewport } from '../types';

export default (viewport: Viewport, newScroll: Position): Viewport => {
Expand All @@ -11,10 +10,12 @@ export default (viewport: Viewport, newScroll: Position): Viewport => {

// We need to update the frame so that it is always a live value
// The top / left of the frame should always match the newScroll position
const change: Position = subtract(diff, viewport.scroll.current);
const frame: Rect = getRect(
offsetByPosition(viewport.frame, change)
);
const frame: Rect = getRect({
top: newScroll.y,
bottom: newScroll.y + viewport.frame.height,
left: newScroll.x,
right: newScroll.x + viewport.frame.width,
});

const updated: Viewport = {
frame,
Expand Down
2 changes: 2 additions & 0 deletions src/view/window/get-viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,7 @@ export default (): Viewport => {
},
};

console.log('viewport', viewport);

return viewport;
};

0 comments on commit edc21bb

Please sign in to comment.