Skip to content

Commit 278c2a8

Browse files
NodoniskoChristoph Pader
andauthored
feat: pan gesture timeout configurable by prop (#43)
* feat: pan gesture timeout configurable by prop * rename panGestureTimout to panGestureDelay Co-authored-by: Christoph Pader <christoph@margelo.io>
1 parent 83550ca commit 278c2a8

4 files changed

Lines changed: 12 additions & 2 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ There are three events fired when the user interacts with the graph:
8282
2. `onPointSelected`: Fired for each point the user pans through. You can use this event to update labels or highlight selection in the graph.
8383
3. `onGestureEnd`: Fired once the user releases his finger and the pan gesture _deactivates_.
8484

85+
Pan gesture can be configures using these props:
86+
87+
1. `panGestureTimeout`: Set timeout for the pan gesture to activate. Set to `0` to start immediately after touch. Defaults to `300`.
88+
8589
Example:
8690

8791
```jsx

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@
126126
"singleQuote": true,
127127
"tabWidth": 2,
128128
"trailingComma": "es5",
129-
"useTabs": false
129+
"useTabs": false,
130+
"semi": false
130131
},
131132
"react-native-builder-bob": {
132133
"source": "src",

src/AnimatedLineGraph.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export function AnimatedLineGraph({
6161
onPointSelected,
6262
onGestureStart,
6363
onGestureEnd,
64+
panGestureDelay = 300,
6465
SelectionDot = DefaultSelectionDot,
6566
enableIndicator = false,
6667
indicatorPulsating = false,
@@ -78,7 +79,7 @@ export function AnimatedLineGraph({
7879

7980
const { gesture, isActive, x } = usePanGesture({
8081
enabled: enablePanGesture,
81-
holdDuration: 300,
82+
holdDuration: panGestureDelay,
8283
})
8384
const circleX = useValue(0)
8485
const circleY = useValue(0)

src/LineGraphProps.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ export type AnimatedLineGraphProps = BaseLineGraphProps & {
7777
* Let's the indicator pulsate
7878
*/
7979
indicatorPulsating?: boolean
80+
/**
81+
* Delay after which the pan gesture starts
82+
*/
83+
panGestureDelay?: number
8084

8185
/**
8286
* Called for each point while the user is scrubbing/panning through the graph

0 commit comments

Comments
 (0)