Skip to content

Commit bf72fb5

Browse files
Glomzzznekomeowww
andauthored
feat(enhanced-readabilities): option to disable animation (#236)
* feat(enhanced-readabilities): option to disable animation * chore: update packages/vitepress-plugin-enhanced-readabilities/src/client/components/LayoutSwitch.vue --------- Co-authored-by: Neko Ayaka <neko@ayaka.moe>
1 parent 37e2bbf commit bf72fb5

6 files changed

Lines changed: 46 additions & 7 deletions

File tree

docs/pages/en/integrations/vitepress-plugin-enhanced-readabilities/index.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,10 @@ export interface Options {
423423
* @default false
424424
*/
425425
disableHelp?: boolean
426+
/**
427+
* Disable Layout Switch animation
428+
*/
429+
disableAnimation?: boolean,
426430
/**
427431
* Default mode for layout switch
428432
*
@@ -445,6 +449,10 @@ export interface Options {
445449
* @default 100 (100%)
446450
*/
447451
defaultMaxWidth?: number
452+
/**
453+
* Disable Layout Max Width animation
454+
*/
455+
disableAnimation?: boolean,
448456
}
449457
/**
450458
* Page layout max width slider configuration
@@ -462,6 +470,10 @@ export interface Options {
462470
* @default 800 (80%)
463471
*/
464472
defaultMaxWidth?: number
473+
/**
474+
* Disable Layout Max Width animation
475+
*/
476+
disableAnimation?: boolean,
465477
}
466478
}
467479
/**
@@ -491,7 +503,7 @@ export interface Options {
491503
*
492504
* @default SpotlightStyle.Aside (2)
493505
*/
494-
defaultStyle?: SpotlightStyles
506+
defaultStyle?: SpotlightStyle
495507
}
496508
}
497509
```

docs/pages/zh-CN/integrations/vitepress-plugin-enhanced-readabilities/index.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,10 @@ export interface Options {
424424
* @default false
425425
*/
426426
disableHelp?: boolean
427+
/**
428+
* Disable Layout Switch animation
429+
*/
430+
disableAnimation?: boolean,
427431
/**
428432
* Default mode for layout switch
429433
*
@@ -446,6 +450,10 @@ export interface Options {
446450
* @default 100 (100%)
447451
*/
448452
defaultMaxWidth?: number
453+
/**
454+
* Disable Layout Max Width animation
455+
*/
456+
disableAnimation?: boolean,
449457
}
450458
/**
451459
* Page layout max width slider configuration
@@ -463,6 +471,10 @@ export interface Options {
463471
* @default 800 (80%)
464472
*/
465473
defaultMaxWidth?: number
474+
/**
475+
* Disable Layout Max Width animation
476+
*/
477+
disableAnimation?: boolean,
466478
}
467479
}
468480
/**
@@ -492,7 +504,7 @@ export interface Options {
492504
*
493505
* @default SpotlightStyle.Aside (2)
494506
*/
495-
defaultStyle?: SpotlightStyles
507+
defaultStyle?: SpotlightStyle
496508
}
497509
}
498510
```

packages/vitepress-plugin-enhanced-readabilities/src/client/components/LayoutSwitch.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ watch(layoutMode, (val) => {
101101
if (!mounted.value)
102102
return
103103
104-
setClasses(val, true)
104+
setClasses(val, !options.layoutSwitch?.disableAnimation)
105105
if (!supportedLayoutModes.includes(val))
106106
layoutMode.value = options.layoutSwitch?.defaultMode || LayoutMode.BothWidthAdjustable
107107
})
108108
109109
watch(route, () => {
110-
setClasses(layoutMode.value, true)
110+
setClasses(layoutMode.value, !options.layoutSwitch?.disableAnimation)
111111
})
112112
113113
watch(isLargerThanMobile, () => {

packages/vitepress-plugin-enhanced-readabilities/src/client/components/LayoutSwitchContentLayoutMaxWidthSlider.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ const { trigger: triggerAnimation } = useLayoutAppearanceChangeAnimation()
5959
6060
const updatePageMaxWidth = useDebounceFn((val: number) => {
6161
if (!shouldActivateMaxWidth.value) {
62-
triggerAnimation(document.body)
62+
if (!options.layoutSwitch?.contentLayoutMaxWidth?.disableAnimation)
63+
triggerAnimation(document.body)
6364
document.body.style.setProperty('--vp-nolebase-enhanced-readabilities-content-max-width', `100%`)
6465
}
6566
else {
66-
triggerAnimation(document.body)
67+
if (!options.layoutSwitch?.contentLayoutMaxWidth?.disableAnimation)
68+
triggerAnimation(document.body)
6769
document.body.style.setProperty('--vp-nolebase-enhanced-readabilities-content-max-width', `${Math.ceil(val / 100)}%`)
6870
}
6971
}, 1000)

packages/vitepress-plugin-enhanced-readabilities/src/client/components/LayoutSwitchPageLayoutMaxWidthSlider.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ const updatePageMaxWidth = useDebounceFn((val: number) => {
6262
document.body.style.setProperty('--vp-nolebase-enhanced-readabilities-page-max-width', `100%`)
6363
}
6464
else {
65-
triggerAnimation(document.body)
65+
if (!options.layoutSwitch?.pageLayoutMaxWidth?.disableAnimation)
66+
triggerAnimation(document.body)
6667
document.body.style.setProperty('--vp-nolebase-enhanced-readabilities-page-max-width', `${Math.ceil(val / 100)}%`)
6768
}
6869
}, 1000)

packages/vitepress-plugin-enhanced-readabilities/src/client/types.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ export interface Options {
294294
* @default LayoutMode.Original (3)
295295
*/
296296
defaultMode?: LayoutMode
297+
/**
298+
* Disable Layout Switch animation
299+
*/
300+
disableAnimation?: boolean
297301
/**
298302
* Content layout max width slider configuration
299303
*/
@@ -310,6 +314,10 @@ export interface Options {
310314
* @default 100 (100%)
311315
*/
312316
defaultMaxWidth?: number
317+
/**
318+
* Disable Layout Max Width animation
319+
*/
320+
disableAnimation?: boolean
313321
}
314322
/**
315323
* Page layout max width slider configuration
@@ -327,6 +335,10 @@ export interface Options {
327335
* @default 800 (80%)
328336
*/
329337
defaultMaxWidth?: number
338+
/**
339+
* Disable Layout Max Width animation
340+
*/
341+
disableAnimation?: boolean
330342
}
331343
}
332344
/**

0 commit comments

Comments
 (0)