Skip to content

Commit

Permalink
feat(animations): add kill option
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyurec committed Oct 22, 2023
1 parent 4cb2975 commit 5bbed90
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
Empty file.
19 changes: 19 additions & 0 deletions src/modules/other/animations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { doc, globals } from '../globals/globals';

import animationsStyles from './animations.css?inline';

export const animationsToggle = () => {
if (globals.pluginConfig.killAnimations) {
animationsLoad();
} else {
animationsUnload();
}
}

export const animationsLoad = () => {
logseq.provideStyle({ key: '--awUi-animations-css', style: animationsStyles });
}

export const animationsUnload = () => {
doc.head.querySelector(`style[data-injected-style^="--awUi-animations-css"]`)?.remove();
}
5 changes: 4 additions & 1 deletion src/plugin/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import { navigationPositionLoad, navigationPositionUnload } from '../modules/hea
import { setTabsCSSVarsStyles, tabsStyleToggle, tabsStyleUnload } from '../modules/extPlugins/tabs/tabsStyle';
import { compactSidebarMenuToggle, compactSidebarMenuUnload } from '../modules/sidebars/compactSidebarMenu/compactSidebarMenu';
import { hideRightSidebarToolbarToggle, hideRightSidebarToolbarUnload } from '../modules/sidebars/hideRightSidebarToolbar/hideRightSidebarToolbar';
import { vaultButtonToggle, vaultButtonUnload } from '../modules/sidebars/vaultButton/vaultButton';
import { animationsToggle, animationsUnload } from '../modules/other/animations';

import '../modules/extPlugins/extPlugins';
import '../modules/other/other';
import { vaultButtonToggle, vaultButtonUnload } from '../modules/sidebars/vaultButton/vaultButton';

export const pluginLoad = () => {
body.classList.add(globals.isPluginEnabled);
Expand Down Expand Up @@ -79,6 +80,7 @@ const runStuff = () => {
tabsStyleToggle();
vaultButtonToggle();
rightSidebarLoad();
animationsToggle();
}, 2000);
}

Expand All @@ -93,6 +95,7 @@ const stopStuff = () => {
tabsPositionUnload();
tabsStyleUnload();
vaultButtonUnload();
animationsUnload();
}

export const onThemeChangedCallback = () => {
Expand Down
4 changes: 4 additions & 0 deletions src/plugin/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { tabsPositionToggle } from '../modules/extPlugins/tabs/tabsPosition';
import { tabsStyleToggle } from '../modules/extPlugins/tabs/tabsStyle';
import { searchStyleToggle } from '../modules/header/searchStyle';
import { navigationPositionToggle } from '../modules/header/navigationPosition';
import { animationsToggle } from '../modules/other/animations';

import './settings.css';
import { vaultButtonToggle } from '../modules/sidebars/vaultButton/vaultButton';
Expand Down Expand Up @@ -63,6 +64,9 @@ export const onSettingsChangedCallback = (settings: LSPluginBaseInfo['settings']
if (settingsChangedKey.includes('vaultButtonToBottom')) {
vaultButtonToggle();
}
if (settingsChangedKey.includes('killAnimations')) {
animationsToggle();
}

setFeaturesCSSVars();
}
7 changes: 7 additions & 0 deletions src/plugin/settingsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,11 @@ export const settingsConfig: SettingSchemaDesc[] = [
type: 'heading',
default: null,
},
{
key: 'killAnimations',
title: '',
description: 'Disable ALL transitions and animations',
type: 'boolean',
default: true,
},
];

0 comments on commit 5bbed90

Please sign in to comment.