Skip to content

Commit 6f6e4c4

Browse files
committed
Bump 0.0.1
1 parent 3255412 commit 6f6e4c4

File tree

4 files changed

+55
-22
lines changed

4 files changed

+55
-22
lines changed

HISTORY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
----
33

44

5+
## 0.0.1 / 2017-07-21
6+
7+
Support Tap, Press, Swipe, Pinch, Rotate

README.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import Gesture from 'rc-gesture';
4545

4646
ReactDOM.render(
4747
<Gesture
48-
onTap={(gesture, event) => { console.log(gesture, event); }}
48+
onTap={(gestureStauts) => { console.log(gestureStauts); }}
4949
>
5050
<div>container</div>
5151
</Gesture>,
@@ -55,7 +55,7 @@ container);
5555

5656
## API
5757

58-
all callback funtion will one parammeter: `(gesture) => {}`
58+
all callback funtion will one parammeter: `type GestureHandler = (s: IGestureStauts) => void;`
5959

6060
- gesture: the rc-gesture state object, container all information you may need, see [gesture](#gesture)
6161

@@ -136,7 +136,7 @@ all callback funtion will one parammeter: `(gesture) => {}`
136136
</tbody>
137137
</table>
138138

139-
#### Pan (**Unsupported Yet*)
139+
#### Pan (**Unsupported Yet**)
140140
<table class="table table-bordered table-striped">
141141
<thead>
142142
<tr>
@@ -289,6 +289,41 @@ pinch gesture is not enabled by default, you must set `props.enableRotate = true
289289

290290
## gesture
291291

292+
```tsx
293+
// http://hammerjs.github.io/api/#event-object
294+
export interface IGestureStauts {
295+
/* start status snapshot */
296+
startTime: number;
297+
startTouches: Finger[];
298+
299+
startMutliFingerStatus?: MultiFingerStatus[];
300+
301+
/* now status snapshot */
302+
time: number;
303+
touches: Finger[];
304+
305+
mutliFingerStatus?: MultiFingerStatus[];
306+
307+
/* delta status from touchstart to now, just for singe finger */
308+
moveStatus?: SingeFingerMoveStatus;
309+
310+
/* whether is a long tap */
311+
press?: boolean;
312+
313+
/* whether is a swipe*/
314+
swipe?: boolean;
315+
direction?: number;
316+
317+
/* whether is in pinch process */
318+
pinch?: boolean;
319+
scale?: number;
320+
321+
/* whether is in rotate process */
322+
rotate?: boolean;
323+
rotation?: number; // Rotation (in deg) that has been done when multi-touch. 0 on a single touch.
324+
};
325+
```
326+
292327
## Development
293328

294329
```

examples/simple.tsx

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,11 @@ class Demo extends Component<any, any> {
3333
}
3434

3535
log = (type: string, keys?: string[]) => (...args) => {
36-
this.doTapOrPress(type, keys, ...args);
36+
console.log(type, ...args);
37+
this.doLog(type, keys, ...args);
3738
this.doTransform(type, ...args);
3839
}
39-
doTapOrPress = (type, keys, ...args) => {
40-
if (['onTap', 'onPress', 'onPressUp'].indexOf(type) === -1) {
41-
return;
42-
}
40+
doLog = (type, keys, ...args) => {
4341
const extInfo = keys ? keys.map(key => `${key} = ${args[0][key]}`).join(', ') : '';
4442
const logEl = this.refs.log as any;
4543
logEl.innerHTML += `<p>${type} ${extInfo}</p>`;
@@ -55,7 +53,6 @@ class Demo extends Component<any, any> {
5553
this._rotation = rotation;
5654
}
5755
let transform: any = [];
58-
// console.log(type, ...args); let transform: any = [];
5956
this._scale && transform.push(`scale(${this._scale})`);
6057
this._rotation && transform.push(`rotate(${this._rotation}deg)`);
6158

@@ -76,18 +73,16 @@ class Demo extends Component<any, any> {
7673
onTap={this.log('onTap')}
7774
onPress={this.log('onPress')}
7875
onPressUp={this.log('onPressUp')}
79-
onSwipe={this.log('onSwipe', ['angle', 'direction'])}
80-
onSwipeLeft = {this.log('onSwipeLeft', ['angle', 'direction'])}
81-
onSwipeRight = {this.log('onSwipeRight', ['angle', 'direction'])}
82-
onSwipeUp = {this.log('onSwipeUp', ['angle', 'direction'])}
83-
onSwipeDown = {this.log('onSwipeDown', ['angle', 'direction'])}
84-
onPan={this.log('onPan')}
85-
onPanStart={this.log('onPanStart')}
86-
onPinch={this.log('onPinch', ['pinchLen', 'scale'])}
87-
onPinchStart={this.log('onPinchStart', ['pinchLen', 'scale'])}
88-
onPinchMove={this.log('onPinchMove', ['pinchLen', 'scale'])}
89-
onPinchEnd={this.log('onPinchEnd', ['pinchLen', 'scale'])}
90-
onPinchCancel={this.log('onPinchCancel', ['pinchLen', 'scale'])}
76+
onSwipe={this.log('onSwipe', ['direction'])}
77+
onSwipeLeft = {this.log('onSwipeLeft', ['direction'])}
78+
onSwipeRight = {this.log('onSwipeRight', ['direction'])}
79+
onSwipeUp = {this.log('onSwipeUp', ['direction'])}
80+
onSwipeDown = {this.log('onSwipeDown', ['direction'])}
81+
onPinch={this.log('onPinch', ['scale'])}
82+
onPinchStart={this.log('onPinchStart', ['scale'])}
83+
onPinchMove={this.log('onPinchMove', ['scale'])}
84+
onPinchEnd={this.log('onPinchEnd', ['scale'])}
85+
onPinchCancel={this.log('onPinchCancel', ['scale'])}
9186
onRotate={this.log('onRotate', ['rotation'])}
9287
onRotateStart={this.log('onRotateStart', ['rotation'])}
9388
onRotateMove={this.log('onRotateMove', ['rotation'])}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"gesture",
1010
"touch"
1111
],
12-
"homepage": "https://react-component.github.io/gesture/",
12+
"homepage": "http://github.com/react-component/gesture/",
1313
"repository": {
1414
"type": "git",
1515
"url": "[email protected]:react-component/gesture.git"

0 commit comments

Comments
 (0)