Telegram Web K with changes to work inside I2P
https://web.telegram.i2p/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.5 KiB
49 lines
1.5 KiB
/* |
|
* https://github.com/morethanwords/tweb |
|
* Copyright (C) 2019-2021 Eduard Kuzmenko |
|
* https://github.com/morethanwords/tweb/blob/master/LICENSE |
|
*/ |
|
|
|
import SwipeHandler, { SwipeHandlerOptions } from "../../components/swipeHandler"; |
|
import cancelEvent from "./cancelEvent"; |
|
import findUpClassName from "./findUpClassName"; |
|
import isSwipingBackSafari from "./isSwipingBackSafari"; |
|
|
|
export type SwipeHandlerHorizontalOptions = SwipeHandlerOptions & { |
|
// xThreshold?: number |
|
}; |
|
|
|
export default function handleHorizontalSwipe(options: SwipeHandlerHorizontalOptions) { |
|
let cancelY = false; |
|
return new SwipeHandler({ |
|
...options, |
|
verifyTouchTarget: (e) => { |
|
return !findUpClassName(e.target, 'progress-line') && |
|
!isSwipingBackSafari(e) && |
|
(options.verifyTouchTarget ? options.verifyTouchTarget(e) : true); |
|
}, |
|
onSwipe: (xDiff, yDiff, e) => { |
|
if(!cancelY && Math.abs(yDiff) > 20) { |
|
return true; |
|
} |
|
|
|
if(Math.abs(xDiff) > Math.abs(yDiff)) { |
|
cancelEvent(e); |
|
cancelY = true; |
|
} else if(!cancelY && Math.abs(yDiff) > Math.abs(xDiff)/* || Math.abs(yDiff) > 20 */) { |
|
return true; |
|
} |
|
|
|
/* if(!cancelY && options.xThreshold !== undefined && xDiff >= options.xThreshold) { |
|
cancelY = true; |
|
} */ |
|
|
|
return options.onSwipe(xDiff, yDiff, e); |
|
}, |
|
onReset: () => { |
|
cancelY = false; |
|
options.onReset && options.onReset(); |
|
}, |
|
cancelEvent: false // cannot use cancelEvent on Safari iOS because scroll will be canceled too |
|
}); |
|
}
|
|
|