Skip to content

Commit

Permalink
change swipe parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSammyM committed Jan 31, 2024
1 parent 0972c83 commit b46ffb5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
1 change: 0 additions & 1 deletion client/src/components/RolePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ export class RoleOutlineOptionSelector extends React.Component<RoleOutlineOption
return translateRoleOutlineOption(roleOutlineOption);
}
render(): React.ReactNode {
console.log("option", this.translateRoleOutlineOptionOrAny(this.props.roleOutlineOption));
return (
<div>
<select
Expand Down
37 changes: 27 additions & 10 deletions client/src/menu/Anchor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ type AnchorState = {
swipeEventListeners: Array<(right: boolean) => void>
}

const MIN_SWIPE_DISTANCE = 75;
const MIN_SWIPE_DISTANCE = 40;
const MAX_SWIPE_DISTANCE = 75;

export default class Anchor extends React.Component<AnchorProps, AnchorState> {
private static instance: Anchor;
Expand Down Expand Up @@ -149,23 +150,39 @@ export default class Anchor extends React.Component<AnchorProps, AnchorState> {
});
}
onTouchMove(e: React.TouchEvent<HTMLDivElement>) {
if(this.state.touchStartX !== null && this.state.touchCurrentX !== null){
if(this.state.touchStartX - this.state.touchCurrentX > MAX_SWIPE_DISTANCE) {

for(let listener of this.state.swipeEventListeners) {
listener(false);
}
}else if(this.state.touchStartX - this.state.touchCurrentX < -MAX_SWIPE_DISTANCE) {

for(let listener of this.state.swipeEventListeners) {
listener(true);
}
}
}


this.setState({
touchCurrentX: e.targetTouches[0].clientX
});
}
onTouchEnd(e: React.TouchEvent<HTMLDivElement>) {

if(this.state.touchStartX === null || this.state.touchCurrentX === null) return;
if(this.state.touchStartX - this.state.touchCurrentX > MIN_SWIPE_DISTANCE) {
for(let listener of this.state.swipeEventListeners) {
listener(false);
}
}
if(this.state.touchStartX - this.state.touchCurrentX < -MIN_SWIPE_DISTANCE) {
for(let listener of this.state.swipeEventListeners) {
listener(true);
if(this.state.touchStartX !== null && this.state.touchCurrentX !== null){
if(this.state.touchStartX - this.state.touchCurrentX > MIN_SWIPE_DISTANCE) {
for(let listener of this.state.swipeEventListeners) {
listener(false);
}
}else if(this.state.touchStartX - this.state.touchCurrentX < -MIN_SWIPE_DISTANCE) {
for(let listener of this.state.swipeEventListeners) {
listener(true);
}
}
}

this.setState({
touchStartX: null,
touchCurrentX: null
Expand Down

0 comments on commit b46ffb5

Please sign in to comment.