Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration from hammer #2157

Merged
merged 43 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
fe6584c
Initial commit
m-bert Jul 21, 2022
68f5abc
test commit
m-bert Jul 21, 2022
f37b37a
access test
m-bert Jul 22, 2022
8b6eef6
test commit
m-bert Jul 22, 2022
6d04613
access test 2
m-bert Jul 22, 2022
9321d6d
Interface manager
m-bert Jul 22, 2022
aa66f83
Orchestrator logic
m-bert Jul 25, 2022
1117f68
Wotking DoubleTap
m-bert Jul 26, 2022
cc63c83
Long-double-single
m-bert Jul 27, 2022
870e8f5
Simultaneous bugfix
m-bert Jul 27, 2022
c03fab0
Pinch fix and rotation
m-bert Jul 29, 2022
a42ebf2
Rotation fix
m-bert Aug 1, 2022
570b1e9
Bouncing box fix
m-bert Aug 1, 2022
51c39fe
Pan velocity fix
m-bert Aug 2, 2022
012ad1b
Added native view
m-bert Aug 2, 2022
8be0e99
Bringing back hammer
m-bert Aug 3, 2022
d694091
organizing project structure
m-bert Aug 3, 2022
0845d3a
added switching to hammer
m-bert Aug 3, 2022
1a3b54e
First refactor
m-bert Aug 3, 2022
8950599
Second refactor
m-bert Aug 3, 2022
7388889
Double draggable fix
m-bert Aug 5, 2022
220cb88
Tap fix
m-bert Aug 5, 2022
6a3ae99
Removing pointer history
m-bert Aug 8, 2022
932a8fc
Added HitSlops
m-bert Aug 8, 2022
87133da
Types fix
m-bert Aug 8, 2022
6235998
Bringing back old examples
m-bert Aug 9, 2022
afe3c15
SVG fix in pinch and rotate
m-bert Aug 9, 2022
47d66c2
Velocity fix for pan
m-bert Aug 9, 2022
1a86d6e
Added missing import in GestureDetector
m-bert Aug 10, 2022
edb1692
Merge branch 'main' into migration-from-hammer
m-bert Aug 10, 2022
e22c207
Pan custom criteria fix
m-bert Aug 10, 2022
d1a3061
Type fixes in handlers
m-bert Aug 10, 2022
5e7a429
Camera example reset
m-bert Aug 10, 2022
1a425de
Changing Alert to window.alert
m-bert Aug 10, 2022
98a9b2b
Removing unnecessary methods and fields
m-bert Aug 11, 2022
15e1df7
Cosmetic changes (renaming methods, changing typos and removing unnec…
m-bert Aug 11, 2022
b62661d
Ignore Safari callbacks error
m-bert Aug 11, 2022
f0dda33
Fixed misssing event data
m-bert Aug 11, 2022
cbf433d
Adding braces to ifs and other minor cosmetic changes
m-bert Aug 12, 2022
12b5229
Changes in checking new implementation logic
m-bert Aug 16, 2022
48e8382
Import fixes
m-bert Aug 16, 2022
67e6576
Merge branch 'main' into migration-from-hammer
m-bert Aug 19, 2022
b48ae82
Type fix in interfaces
m-bert Aug 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
access test 2
  • Loading branch information
m-bert committed Jul 22, 2022
commit 6d04613022ff9397b6107da54e7adc964c6df1a6
16 changes: 8 additions & 8 deletions example/src/basic/multitap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ export class PressBox extends Component<PressBoxProps> {
// <LongPressGestureHandler
// onHandlerStateChange={this.onHandlerStateChange}
// minDurationMs={800}>
// <TapGestureHandler
// onHandlerStateChange={this.onSingleTap}
// waitFor={this.doubleTapRef}>
<TapGestureHandler
ref={this.doubleTapRef}
onHandlerStateChange={this.onDoubleTap}
numberOfTaps={2}>
<View style={styles.box} />
onHandlerStateChange={this.onSingleTap}
waitFor={this.doubleTapRef}>
<TapGestureHandler
ref={this.doubleTapRef}
onHandlerStateChange={this.onDoubleTap}
numberOfTaps={2}>
<View style={styles.box} />
</TapGestureHandler>
</TapGestureHandler>
// </TapGestureHandler>
// </LongPressGestureHandler>
);
}
Expand Down
30 changes: 16 additions & 14 deletions src/web/GestureHandler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { findNodeHandle } from '../handlers/gestureHandlerCommon';
import { findNodeHandle } from 'react-native';
import { State } from '../State';
import EventManager, { GHEvent } from './EventManager';
import GestureHandlerOrchestrator from './GestureHandlerOrchestrator';
Expand Down Expand Up @@ -75,6 +75,7 @@ abstract class GestureHandler {
// protected __initialX: any;
// protected __initialY: any;
protected config: Config = {};
protected enabled = false;
// protected previousState: State = State.UNDETERMINED;
private pendingGestures: Record<string, this> = {};
// private oldState: State = State.UNDETERMINED;
Expand Down Expand Up @@ -108,16 +109,16 @@ abstract class GestureHandler {
this.hasCustomActivationCriteria = false;
}

getConfig() {
protected getConfig() {
return this.config;
}

removePendingGestures(id: string) {
protected removePendingGestures(id: string) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete this.pendingGestures[id];
}

addPendingGesture(gesture: this) {
public addPendingGesture(gesture: this) {
this.pendingGestures[gesture.id] = gesture;
}

Expand All @@ -129,7 +130,7 @@ abstract class GestureHandler {
}
}

updateGestureConfig({ enabled = true, ...props }): void {
public updateGestureConfig({ enabled = true, ...props }): void {
this.clearSelfAsPending();

this.config = this.ensureConfig({ enabled, ...props });
Expand All @@ -142,7 +143,7 @@ abstract class GestureHandler {
}
}

getState(): State {
public getState(): State {
return this.currentState;
}

Expand Down Expand Up @@ -184,11 +185,11 @@ abstract class GestureHandler {
this.eventManager.setOutOfBoundsAction(this.onOutOfBoundsAction.bind(this));
}

destroy() {
public destroy() {
this.clearSelfAsPending();
}

ensureConfig(config: Config): Required<Config> {
private ensureConfig(config: Config): Required<Config> {
const props = { ...config };

if (config.minDist) {
Expand Down Expand Up @@ -239,7 +240,7 @@ abstract class GestureHandler {
return props as Required<Config>;
}

asArray<T>(value: T | T[]) {
private asArray<T>(value: T | T[]) {
return !value ? [] : Array.isArray(value) ? value : [value];
}

Expand All @@ -248,8 +249,8 @@ abstract class GestureHandler {
}

//Handling states changes
abstract onCancel(): void;
abstract onReset(): void;
protected abstract onCancel(): void;
protected abstract onReset(): void;
protected resetProgress(): void {
//
}
Expand All @@ -270,7 +271,7 @@ abstract class GestureHandler {
public moveToState(newState: State, event: GHEvent) {
if (this.currentState === newState) return;

console.log(newState, this.currentState);
// console.log(`${this.currentState} -> ${newState}`);

if (
this.tracker.getTrackedPointersNumber() > 0 &&
Expand Down Expand Up @@ -326,7 +327,7 @@ abstract class GestureHandler {
}
}

protected activate(event: GHEvent, _force = false) {
protected activate(event: GHEvent, force = false) {
if (
this.currentState === State.UNDETERMINED ||
this.currentState === State.BEGAN
Expand All @@ -336,7 +337,8 @@ abstract class GestureHandler {
}

public end(event: GHEvent) {
if (this.getState() !== State.ACTIVE) this.resetProgress();
// if (this.getState() !== State.ACTIVE) this.resetProgress();
this.resetProgress();
if (this.currentState === State.BEGAN || this.currentState === State.ACTIVE)
this.moveToState(State.END, event);
}
Expand Down
4 changes: 1 addition & 3 deletions src/web/GestureHandlerOrchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ export default class GestureHandlerOrchestrator {
oldState: State,
event: GHEvent
): void {
// console.log(getKeyByValue(newState));
// console.log(getKeyByValue(oldState));
// console.log(event);
// console.log(oldState, newState, handler.id);
handler.sendEvent(event, newState, oldState);
}

Expand Down
37 changes: 17 additions & 20 deletions src/web/PanGestureHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class PanGestureHandler extends GestureHandler {
private defaultMinDistSq: number =
this.DEFAULT_TOUCH_SLOP * this.DEFAULT_TOUCH_SLOP;

private enabled = false;

private minDistSq = this.defaultMinDistSq;

private activeOffsetXStart = Number.MAX_SAFE_INTEGER;
Expand Down Expand Up @@ -73,7 +71,7 @@ class PanGestureHandler extends GestureHandler {
return 'pan';
}

updateGestureConfig({ ...props }): void {
public updateGestureConfig({ ...props }): void {
super.updateGestureConfig({ enabled: true, ...props });

for (const key in this.config) {
Expand Down Expand Up @@ -143,7 +141,7 @@ class PanGestureHandler extends GestureHandler {
}
}

transformNativeEvent(event: GHEvent): any {
protected transformNativeEvent(event: GHEvent): any {
if (!this.view) return;

const rect = this.view.getBoundingClientRect();
Expand Down Expand Up @@ -186,19 +184,17 @@ class PanGestureHandler extends GestureHandler {
this.activateAfterLongPress = 0;
}

getTranslationX(): number {
private getTranslationX(): number {
return this.lastX - this.startX + this.offsetX;
}
getTranslationY(): number {
private getTranslationY(): number {
return this.lastY - this.startY + this.offsetY;
}

//EventsHandling
onDownAction(event: GHEvent): void {
protected onDownAction(event: GHEvent): void {
super.onDownAction(event);

this.tracker.addToTracker(event.pointerId);
this.tracker.track(event);
this.tracker.addToTracker(event);

if (this.tracker.getTrackedPointersNumber() > 1) {
event.eventType = EventTypes.POINTER_DOWN;
Expand All @@ -212,7 +208,7 @@ class PanGestureHandler extends GestureHandler {
this.checkUndetermined(event);
this.checkBegan(event);
}
onPointerAdd(event: GHEvent): void {
protected onPointerAdd(event: GHEvent): void {
this.offsetX += this.lastX - this.startX;
this.offsetY += this.lastY - this.startY;

Expand All @@ -230,7 +226,7 @@ class PanGestureHandler extends GestureHandler {
} else this.checkBegan(event);
}

onUpAction(event: GHEvent): void {
protected onUpAction(event: GHEvent): void {
super.onUpAction(event);

if (this.tracker.getTrackedPointersNumber() > 1) {
Expand All @@ -257,7 +253,7 @@ class PanGestureHandler extends GestureHandler {
this.fail(event);
}
}
onPointerRemove(event: GHEvent): void {
protected onPointerRemove(event: GHEvent): void {
this.offsetX += this.lastX - this.startX;
this.offsetY += this.lastY - this.startY;

Expand All @@ -275,10 +271,11 @@ class PanGestureHandler extends GestureHandler {
) {
this.resetProgress();
this.fail(event);
// this.end(event);
} else this.checkBegan(event);
}

onMoveAction(event: GHEvent): void {
protected onMoveAction(event: GHEvent): void {
this.tracker.track(event);

this.lastX = this.tracker.getLastAvgX();
Expand All @@ -289,19 +286,19 @@ class PanGestureHandler extends GestureHandler {

if (this.getState() === State.ACTIVE) super.onMoveAction(event);
}
onOutAction(event: GHEvent): void {
protected onOutAction(event: GHEvent): void {
super.onOutAction(event);
}
onEnterAction(event: GHEvent): void {
protected onEnterAction(event: GHEvent): void {
super.onEnterAction(event);
}
onCancelAction(event: GHEvent): void {
protected onCancelAction(event: GHEvent): void {
super.onCancelAction(event);

this.tracker.resetTracker();
this.fail(event);
}
onOutOfBoundsAction(event: GHEvent): void {
protected onOutOfBoundsAction(event: GHEvent): void {
this.tracker.track(event);

this.lastX = this.tracker.getLastAvgX();
Expand Down Expand Up @@ -460,10 +457,10 @@ class PanGestureHandler extends GestureHandler {
this.startY = this.lastY;
}

onCancel(): void {
protected onCancel(): void {
//
}
onReset(): void {
protected onReset(): void {
//
}
}
Expand Down
Loading