mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Android: Fix images/resources long press - do not show menu on pinch zoom (#4275)
This commit is contained in:
parent
0e57baf5b9
commit
8492a7ee26
@ -82,9 +82,7 @@ export default function useSource(noteBody: string, noteMarkupLanguage: number,
|
|||||||
resources: noteResources,
|
resources: noteResources,
|
||||||
codeTheme: theme.codeThemeCss,
|
codeTheme: theme.codeThemeCss,
|
||||||
postMessageSyntax: 'window.joplinPostMessage_',
|
postMessageSyntax: 'window.joplinPostMessage_',
|
||||||
// Disabled for now as it causes issues when zooming in or out
|
enableLongPress: shim.mobilePlatform() === 'android', // On iOS, there's already a built-on open/share menu
|
||||||
// https://github.com/laurent22/joplin/pull/3939#issuecomment-734260166
|
|
||||||
enableLongPress: false, // shim.mobilePlatform() === 'android', // On iOS, there's already a built-on open/share menu
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Whenever a resource state changes, for example when it goes from "not downloaded" to "downloaded", the "noteResources"
|
// Whenever a resource state changes, for example when it goes from "not downloaded" to "downloaded", the "noteResources"
|
||||||
|
@ -91,7 +91,9 @@ export default function(href: string, options: Options = null): LinkReplacementR
|
|||||||
if (options.enableLongPress && !!resourceId) {
|
if (options.enableLongPress && !!resourceId) {
|
||||||
const onClick = `${options.postMessageSyntax}(${JSON.stringify(href)})`;
|
const onClick = `${options.postMessageSyntax}(${JSON.stringify(href)})`;
|
||||||
const onLongClick = `${options.postMessageSyntax}("longclick:${resourceId}")`;
|
const onLongClick = `${options.postMessageSyntax}("longclick:${resourceId}")`;
|
||||||
const touchStart = `t=setTimeout(()=>{t=null; ${onLongClick};}, ${utils.longPressDelay});`;
|
// if t is set when ontouchstart is called it means the user has already touched the screen once and this is the 2nd touch
|
||||||
|
// in this case we assume the user is trying to zoom and we don't want to show the menu
|
||||||
|
const touchStart = `if (typeof(t) !== "undefined" && !!t) { clearTimeout(t); t = null; } else { t = setTimeout(() => { t = null; ${onLongClick}; }, ${utils.longPressDelay}); }`;
|
||||||
const cancel = 'if (!!t) {clearTimeout(t); t=null;';
|
const cancel = 'if (!!t) {clearTimeout(t); t=null;';
|
||||||
const touchEnd = `${cancel} ${onClick};}`;
|
const touchEnd = `${cancel} ${onClick};}`;
|
||||||
js = `ontouchstart='${touchStart}' ontouchend='${touchEnd}' ontouchcancel='${cancel} ontouchmove="${cancel}'`;
|
js = `ontouchstart='${touchStart}' ontouchend='${touchEnd}' ontouchcancel='${cancel} ontouchmove="${cancel}'`;
|
||||||
|
@ -22,7 +22,9 @@ function plugin(markdownIt: any, ruleOptions: RuleOptions) {
|
|||||||
const id = r['data-resource-id'];
|
const id = r['data-resource-id'];
|
||||||
|
|
||||||
const longPressHandler = `${ruleOptions.postMessageSyntax}('longclick:${id}')`;
|
const longPressHandler = `${ruleOptions.postMessageSyntax}('longclick:${id}')`;
|
||||||
const touchStart = `t=setTimeout(()=>{t=null; ${longPressHandler};}, ${utils.longPressDelay});`;
|
// if t is set when ontouchstart is called it means the user has already touched the screen once and this is the 2nd touch
|
||||||
|
// in this case we assume the user is trying to zoom and we don't want to show the menu
|
||||||
|
const touchStart = `if (typeof(t) !== 'undefined' && !!t) { clearTimeout(t); t = null; } else { t = setTimeout(() => { t = null; ${longPressHandler}; }, ${utils.longPressDelay}); }`;
|
||||||
const cancel = 'if (!!t) clearTimeout(t); t=null';
|
const cancel = 'if (!!t) clearTimeout(t); t=null';
|
||||||
|
|
||||||
js = ` ontouchstart="${touchStart}" ontouchend="${cancel}" ontouchcancel="${cancel}" ontouchmove="${cancel}"`;
|
js = ` ontouchstart="${touchStart}" ontouchend="${cancel}" ontouchcancel="${cancel}" ontouchmove="${cancel}"`;
|
||||||
|
Loading…
Reference in New Issue
Block a user