mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-11 11:32:52 +08:00
refactor(responsive-observe): improve typescript type (#27305)
This commit is contained in:
parent
a442722cd2
commit
6e0981d1df
@ -1,5 +1,5 @@
|
|||||||
export type Breakpoint = 'xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs';
|
export type Breakpoint = 'xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs';
|
||||||
export type BreakpointMap = Partial<Record<Breakpoint, string>>;
|
export type BreakpointMap = Record<Breakpoint, string>;
|
||||||
export type ScreenMap = Partial<Record<Breakpoint, boolean>>;
|
export type ScreenMap = Partial<Record<Breakpoint, boolean>>;
|
||||||
export type ScreenSizeMap = Partial<Record<Breakpoint, number>>;
|
export type ScreenSizeMap = Partial<Record<Breakpoint, number>>;
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ const responsiveObserve = {
|
|||||||
},
|
},
|
||||||
unregister() {
|
unregister() {
|
||||||
Object.keys(responsiveMap).forEach((screen: Breakpoint) => {
|
Object.keys(responsiveMap).forEach((screen: Breakpoint) => {
|
||||||
const matchMediaQuery = responsiveMap[screen]!;
|
const matchMediaQuery = responsiveMap[screen];
|
||||||
const handler = this.matchHandlers[matchMediaQuery];
|
const handler = this.matchHandlers[matchMediaQuery];
|
||||||
handler?.mql.removeListener(handler?.listener);
|
handler?.mql.removeListener(handler?.listener);
|
||||||
});
|
});
|
||||||
@ -52,7 +52,7 @@ const responsiveObserve = {
|
|||||||
},
|
},
|
||||||
register() {
|
register() {
|
||||||
Object.keys(responsiveMap).forEach((screen: Breakpoint) => {
|
Object.keys(responsiveMap).forEach((screen: Breakpoint) => {
|
||||||
const matchMediaQuery = responsiveMap[screen]!;
|
const matchMediaQuery = responsiveMap[screen];
|
||||||
const listener = ({ matches }: { matches: boolean }) => {
|
const listener = ({ matches }: { matches: boolean }) => {
|
||||||
this.dispatch({
|
this.dispatch({
|
||||||
...screens,
|
...screens,
|
||||||
|
Loading…
Reference in New Issue
Block a user