mirror of
https://github.com/discourse/discourse.git
synced 2025-03-01 14:50:55 +08:00
DEV: applyBehaviorTransformer for composer-position editTouchMove (#30811)
In a theme or plugin, if you have a scrollable mobile composer, you may want to allow scrolling events on the composer editor.. this allows for it!
This commit is contained in:
parent
72f4588d3b
commit
e6272e0497
@ -1,4 +1,5 @@
|
|||||||
import { later } from "@ember/runloop";
|
import { later } from "@ember/runloop";
|
||||||
|
import { applyBehaviorTransformer } from "discourse/lib/transformer";
|
||||||
|
|
||||||
export function setupComposerPosition(editor) {
|
export function setupComposerPosition(editor) {
|
||||||
// This component contains two composer positioning adjustments
|
// This component contains two composer positioning adjustments
|
||||||
@ -10,11 +11,13 @@ export function setupComposerPosition(editor) {
|
|||||||
// This is an alternative to locking up the body
|
// This is an alternative to locking up the body
|
||||||
// It stops scrolling in the given element from bubbling up to the body
|
// It stops scrolling in the given element from bubbling up to the body
|
||||||
// when the editor does not have any content to scroll
|
// when the editor does not have any content to scroll
|
||||||
|
applyBehaviorTransformer("composer-position:editor-touch-move", () => {
|
||||||
const notScrollable = editor.scrollHeight <= editor.clientHeight;
|
const notScrollable = editor.scrollHeight <= editor.clientHeight;
|
||||||
if (notScrollable) {
|
if (notScrollable) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
export const BEHAVIOR_TRANSFORMERS = Object.freeze([
|
export const BEHAVIOR_TRANSFORMERS = Object.freeze([
|
||||||
// use only lowercase names
|
// use only lowercase names
|
||||||
|
"composer-position:editor-touch-move",
|
||||||
"discovery-topic-list-load-more",
|
"discovery-topic-list-load-more",
|
||||||
"full-page-search-load-more",
|
"full-page-search-load-more",
|
||||||
]);
|
]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user