forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[D&D] Dropbox style and animations (opensearch-project#1863)
* fix dropbox styles and added animations Signed-off-by: Ashwin Pc <ashwinpc@amazon.com> * simpler usePrefersReducedMotion Signed-off-by: Ashwin Pc <ashwinpc@amazon.com> * fix drop target animation Signed-off-by: Ashwin Pc <ashwinpc@amazon.com>
- Loading branch information
Showing
4 changed files
with
109 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/plugins/wizard/public/application/components/data_tab/use/use_prefers_reduced_motion.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { useEffect, useState } from 'react'; | ||
|
||
const QUERY = '(prefers-reduced-motion: no-preference)'; | ||
|
||
export function usePrefersReducedMotion() { | ||
const [prefersReducedMotion, setPrefersReducedMotion] = useState( | ||
!window.matchMedia(QUERY).matches | ||
); | ||
|
||
useEffect(() => { | ||
const mediaQueryList = window.matchMedia(QUERY); | ||
const listener = (event) => { | ||
setPrefersReducedMotion(!event.matches); | ||
}; | ||
|
||
if (mediaQueryList.addEventListener) { | ||
mediaQueryList.addEventListener('change', listener); | ||
} | ||
|
||
return () => { | ||
mediaQueryList.removeEventListener('change', listener); | ||
}; | ||
}, []); | ||
|
||
return prefersReducedMotion; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters