mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
Remove reducedMotion store and use body class instead
This commit is contained in:
parent
6929af6d43
commit
563ed8a9ab
5 changed files with 6 additions and 23 deletions
|
@ -534,7 +534,6 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too
|
||||||
setColorButtons({});
|
setColorButtons({});
|
||||||
setTags({});
|
setTags({});
|
||||||
setMathjaxEnabled({});
|
setMathjaxEnabled({});
|
||||||
setReducedMotion({});
|
|
||||||
""".format(
|
""".format(
|
||||||
json.dumps(data),
|
json.dumps(data),
|
||||||
json.dumps(collapsed),
|
json.dumps(collapsed),
|
||||||
|
@ -546,7 +545,6 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too
|
||||||
json.dumps([text_color, highlight_color]),
|
json.dumps([text_color, highlight_color]),
|
||||||
json.dumps(self.note.tags),
|
json.dumps(self.note.tags),
|
||||||
json.dumps(self.mw.col.get_config("renderMathjax", True)),
|
json.dumps(self.mw.col.get_config("renderMathjax", True)),
|
||||||
json.dumps(self.mw.pm.reduced_motion()),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.addMode:
|
if self.addMode:
|
||||||
|
|
|
@ -8,12 +8,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import { tweened } from "svelte/motion";
|
import { tweened } from "svelte/motion";
|
||||||
|
|
||||||
export let collapse = false;
|
export let collapse = false;
|
||||||
export let animated = true;
|
|
||||||
export let duration = 200;
|
export let duration = 200;
|
||||||
|
|
||||||
let collapsed = false;
|
let collapsed = false;
|
||||||
let contentHeight = 0;
|
let contentHeight = 0;
|
||||||
|
|
||||||
|
let animated = !document.body.classList.contains("reduced-motion");
|
||||||
|
|
||||||
function dynamicDuration(height: number): number {
|
function dynamicDuration(height: number): number {
|
||||||
return 100 + Math.pow(height, 1 / 4) * 25;
|
return 100 + Math.pow(height, 1 / 4) * 25;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,12 +42,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { getContext, onDestroy, setContext } from "svelte";
|
import { onDestroy, setContext } from "svelte";
|
||||||
import type { Writable } from "svelte/store";
|
import type { Writable } from "svelte/store";
|
||||||
import { writable } from "svelte/store";
|
import { writable } from "svelte/store";
|
||||||
|
|
||||||
import Collapsible from "../components/Collapsible.svelte";
|
import Collapsible from "../components/Collapsible.svelte";
|
||||||
import { collapsedKey, directionKey, reducedMotionKey } from "../lib/context-keys";
|
import { collapsedKey, directionKey } from "../lib/context-keys";
|
||||||
import { promiseWithResolver } from "../lib/promise";
|
import { promiseWithResolver } from "../lib/promise";
|
||||||
import type { Destroyable } from "./destroyable";
|
import type { Destroyable } from "./destroyable";
|
||||||
import EditingArea from "./EditingArea.svelte";
|
import EditingArea from "./EditingArea.svelte";
|
||||||
|
@ -67,8 +67,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
$: $collapsedStore = collapsed;
|
$: $collapsedStore = collapsed;
|
||||||
|
|
||||||
const reducedMotion = getContext<Readable<boolean>>(reducedMotionKey);
|
|
||||||
|
|
||||||
const editingArea: Partial<EditingAreaAPI> = {};
|
const editingArea: Partial<EditingAreaAPI> = {};
|
||||||
const [element, elementResolve] = promiseWithResolver<HTMLElement>();
|
const [element, elementResolve] = promiseWithResolver<HTMLElement>();
|
||||||
|
|
||||||
|
@ -90,7 +88,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
<div class="field-container" on:mouseenter on:mouseleave>
|
<div class="field-container" on:mouseenter on:mouseleave>
|
||||||
<slot name="field-label" />
|
<slot name="field-label" />
|
||||||
|
|
||||||
<Collapsible collapse={collapsed} animated={!$reducedMotion} let:collapsed={hidden}>
|
<Collapsible collapse={collapsed} let:collapsed={hidden}>
|
||||||
<div use:elementResolve class="editor-field" on:focusin on:focusout {hidden}>
|
<div use:elementResolve class="editor-field" on:focusin on:focusout {hidden}>
|
||||||
<EditingArea
|
<EditingArea
|
||||||
{content}
|
{content}
|
||||||
|
|
|
@ -39,14 +39,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount, setContext, tick } from "svelte";
|
import { onMount, tick } from "svelte";
|
||||||
import { get, writable } from "svelte/store";
|
import { get, writable } from "svelte/store";
|
||||||
|
|
||||||
import Absolute from "../components/Absolute.svelte";
|
import Absolute from "../components/Absolute.svelte";
|
||||||
import Badge from "../components/Badge.svelte";
|
import Badge from "../components/Badge.svelte";
|
||||||
import StickyContainer from "../components/StickyContainer.svelte";
|
import StickyContainer from "../components/StickyContainer.svelte";
|
||||||
import { bridgeCommand } from "../lib/bridgecommand";
|
import { bridgeCommand } from "../lib/bridgecommand";
|
||||||
import { reducedMotionKey } from "../lib/context-keys";
|
|
||||||
import { TagEditor } from "../tag-editor";
|
import { TagEditor } from "../tag-editor";
|
||||||
import { ChangeTimer } from "./change-timer";
|
import { ChangeTimer } from "./change-timer";
|
||||||
import DecoratedElements from "./DecoratedElements.svelte";
|
import DecoratedElements from "./DecoratedElements.svelte";
|
||||||
|
@ -130,15 +129,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
plainTextDefaults = [...richTextsHidden];
|
plainTextDefaults = [...richTextsHidden];
|
||||||
}
|
}
|
||||||
|
|
||||||
let reducedMotion = false;
|
|
||||||
function setReducedMotion(enabled: boolean): void {
|
|
||||||
reducedMotion = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
const reducedMotionStore = writable<boolean>();
|
|
||||||
setContext(reducedMotionKey, reducedMotionStore);
|
|
||||||
$: $reducedMotionStore = reducedMotion;
|
|
||||||
|
|
||||||
function setMathjaxEnabled(enabled: boolean): void {
|
function setMathjaxEnabled(enabled: boolean): void {
|
||||||
mathjaxConfig.enabled = enabled;
|
mathjaxConfig.enabled = enabled;
|
||||||
}
|
}
|
||||||
|
@ -287,7 +277,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
setNoteId,
|
setNoteId,
|
||||||
wrap,
|
wrap,
|
||||||
setMathjaxEnabled,
|
setMathjaxEnabled,
|
||||||
setReducedMotion,
|
|
||||||
...oldEditorAdapter,
|
...oldEditorAdapter,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -447,7 +436,6 @@ the AddCards dialog) should be implemented in the user of this component.
|
||||||
<svelte:fragment slot="rich-text-input">
|
<svelte:fragment slot="rich-text-input">
|
||||||
<Collapsible
|
<Collapsible
|
||||||
collapse={richTextsHidden[index]}
|
collapse={richTextsHidden[index]}
|
||||||
animated={!reducedMotion}
|
|
||||||
let:collapsed={hidden}
|
let:collapsed={hidden}
|
||||||
>
|
>
|
||||||
<RichTextInput
|
<RichTextInput
|
||||||
|
@ -469,7 +457,6 @@ the AddCards dialog) should be implemented in the user of this component.
|
||||||
<svelte:fragment slot="plain-text-input">
|
<svelte:fragment slot="plain-text-input">
|
||||||
<Collapsible
|
<Collapsible
|
||||||
collapse={plainTextsHidden[index]}
|
collapse={plainTextsHidden[index]}
|
||||||
animated={!reducedMotion}
|
|
||||||
let:collapsed={hidden}
|
let:collapsed={hidden}
|
||||||
>
|
>
|
||||||
<PlainTextInput
|
<PlainTextInput
|
||||||
|
|
|
@ -6,4 +6,3 @@ export const fontSizeKey = Symbol("fontSize");
|
||||||
export const directionKey = Symbol("direction");
|
export const directionKey = Symbol("direction");
|
||||||
export const descriptionKey = Symbol("description");
|
export const descriptionKey = Symbol("description");
|
||||||
export const collapsedKey = Symbol("collapsed");
|
export const collapsedKey = Symbol("collapsed");
|
||||||
export const reducedMotionKey = Symbol("reducedMotion");
|
|
||||||
|
|
Loading…
Reference in a new issue