Skip to content

Commit b3acc19

Browse files
feat: introduce reduceMotion option (#102)
1 parent 1fa70c3 commit b3acc19

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

packages/core/src/Overlay.vue

+13-4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default {
3333
column: 0,
3434
},
3535
KEY_IGNORE,
36+
animation: !inspectorOptions.reduceMotion,
3637
}
3738
},
3839
computed: {
@@ -308,7 +309,7 @@ export default {
308309
<template v-if="overlayVisible && linkParams">
309310
<div
310311
ref="floatsRef"
311-
class="vue-inspector-floats vue-inspector-card"
312+
class="vue-inspector-floats vue-inspector-card" :class="[{ 'vue-inspector-animated': animation }]"
312313
:style="floatsStyle"
313314
>
314315
<div>{{ linkParams.title }}:{{ linkParams.line }}:{{ linkParams.column }}</div>
@@ -317,7 +318,7 @@ export default {
317318
</div>
318319
</div>
319320
<div
320-
class="vue-inspector-size-indicator"
321+
class="vue-inspector-size-indicator" :class="[{ 'vue-inspector-animated': animation }]"
321322
:style="sizeIndicatorStyle"
322323
/>
323324
</template>
@@ -369,7 +370,6 @@ export default {
369370
z-index: 2147483647;
370371
position: fixed;
371372
transform: translateX(-50%);
372-
transition: all 0.1s ease-in;
373373
pointer-events: none;
374374
}
375375
@@ -379,7 +379,16 @@ export default {
379379
background-color:#42b88325;
380380
border: 1px solid #42b88350;
381381
border-radius: 5px;
382-
transition: all 0.1s ease-in;
383382
pointer-events: none;
384383
}
384+
385+
.vue-inspector-animated {
386+
transition: all 0.1s ease-in;
387+
}
388+
389+
@media (prefers-reduced-motion) {
390+
.vue-inspector-animated {
391+
transition: none !important;
392+
}
393+
}
385394
</style>

packages/core/src/index.ts

+7
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ export interface VitePluginInspectorOptions {
110110
* @default process.env.LAUNCH_EDITOR ?? code (Visual Studio Code)
111111
*/
112112
launchEditor?: 'appcode' | 'atom' | 'atom-beta' | 'brackets' | 'clion' | 'code' | 'code-insiders' | 'codium' | 'emacs' | 'idea' | 'notepad++' | 'pycharm' | 'phpstorm' | 'rubymine' | 'sublime' | 'vim' | 'visualstudio' | 'webstorm' | 'rider' | string
113+
114+
/**
115+
* Disable animation/transition, will auto disable when `prefers-reduced-motion` is set
116+
* @default false
117+
*/
118+
reduceMotion?: boolean
113119
}
114120

115121
const toggleComboKeysMap = {
@@ -136,6 +142,7 @@ export const DEFAULT_INSPECTOR_OPTIONS: VitePluginInspectorOptions = {
136142
appendTo: '',
137143
lazyLoad: false,
138144
launchEditor: process.env.LAUNCH_EDITOR ?? 'code',
145+
reduceMotion: false,
139146
} as const
140147

141148
function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPECTOR_OPTIONS): PluginOption {

0 commit comments

Comments
 (0)