Skip to content

Commit

Permalink
Auto scroll grab near edge (#976)
Browse files Browse the repository at this point in the history
Fixes #349
  • Loading branch information
alexreardon committed Dec 7, 2018
1 parent b7d549c commit ac57253
Show file tree
Hide file tree
Showing 41 changed files with 2,454 additions and 2,095 deletions.
24 changes: 12 additions & 12 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"dist/react-beautiful-dnd.js": {
"bundled": 339807,
"minified": 130844,
"gzipped": 38870
"bundled": 346497,
"minified": 133751,
"gzipped": 39617
},
"dist/react-beautiful-dnd.min.js": {
"bundled": 289271,
"minified": 107397,
"gzipped": 31390
"bundled": 295050,
"minified": 109602,
"gzipped": 31921
},
"dist/react-beautiful-dnd.esm.js": {
"bundled": 221375,
"minified": 116185,
"gzipped": 29093,
"bundled": 228302,
"minified": 120073,
"gzipped": 29861,
"treeshaked": {
"rollup": {
"code": 79771,
"import_statements": 791
"code": 81952,
"import_statements": 846
},
"webpack": {
"code": 82339
"code": 84571
}
}
}
Expand Down
1 change: 1 addition & 0 deletions docs/media.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ This page contains a list of articles, blogs and newsletters that `react-beautif
- [Want To Recruit Better Engineers? Open Source Your Code](https://angel.co/blog/want-to-recruit-better-engineers-open-source-your-code)
- [How To Implement Better Drag and Drop in your React App](https://blog.bitsrc.io/implement-better-drag-and-drop-in-your-react-app-beafc4451599)
- [Beautiful drag and drop with React — The beginner’s guide](https://medium.com/@AlejandroSobko/7798e3928290)
- [The New Jira Beings Now (in the examples)](https://www.atlassian.com/blog/jira-software/the-new-jira-begins-now)
- 15 Awesome React Components [Article](https://tutorialzine.com/2017/11/15-awesome-react-components)
- 15 Interesting JavaScript and CSS Libraries for September 2017 [September edition](https://tutorialzine.com/2017/09/15-interesting-javascript-and-css-libraries-for-september-2017)
- Mybridge React.JS Top 10 Articles For the Past Month [v.Sep 2017](https://medium.mybridge.co/react-js-top-10-articles-for-the-past-month-v-sep-2017-1894c4d91e0c)
Expand Down
9 changes: 5 additions & 4 deletions src/state/auto-scroller/auto-scroller-types.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// @flow
import type { DraggingState } from '../../types';
import type { State, DraggingState } from '../../types';

export type AutoScroller = {|
cancel: () => void,
jumpScroll: (state: DraggingState) => void,
fluidScroll: (state: DraggingState) => void,
start: (state: DraggingState) => void,
stop: () => void,
cancelPending: () => void,
scroll: (state: State) => void,
|};
278 changes: 0 additions & 278 deletions src/state/auto-scroller/fluid-scroller.js

This file was deleted.

25 changes: 25 additions & 0 deletions src/state/auto-scroller/fluid-scroller/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// @flow

// Values used to control how the fluid auto scroll feels
const config = {
// percentage distance from edge of container:
startFromPercentage: 0.25,
maxScrollAtPercentage: 0.05,
// pixels per frame
maxPixelScroll: 28,

// A function used to ease a percentage value
// A simple linear function would be: (percentage) => percentage;
// percentage is between 0 and 1
// result must be between 0 and 1
ease: (percentage: number): number => Math.pow(percentage, 2),

durationDampening: {
// ms: how long to dampen the speed of an auto scroll from the start of a drag
stopDampeningAt: 1200,
// ms: when to start accelerating the reduction of duration dampening
accelerateAt: 360,
},
};

export default config;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// @flow
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import memoizeOne from 'memoize-one';
import invariant from 'tiny-invariant';
import { type Position } from 'css-box-model';
import isPositionInFrame from '../visibility/is-position-in-frame';
import { toDroppableList } from '../dimension-structures';
import { find } from '../../native-with-fallback';
import type {
DroppableDimension,
DroppableDimensionMap,
DroppableId,
} from '../../types';
} from '../../../types';
import isPositionInFrame from '../../visibility/is-position-in-frame';
import { toDroppableList } from '../../dimension-structures';
import { find } from '../../../native-with-fallback';

const getScrollableDroppables = memoizeOne(
(droppables: DroppableDimensionMap): DroppableDimension[] =>
Expand Down
Loading

0 comments on commit ac57253

Please sign in to comment.