commit | author | age
|
9bcb19
|
1 |
import enquireJs from 'enquire.js' |
I |
2 |
|
|
3 |
export const DEVICE_TYPE = { |
|
4 |
DESKTOP: 'desktop', |
|
5 |
TABLET: 'tablet', |
|
6 |
MOBILE: 'mobile' |
|
7 |
} |
|
8 |
|
|
9 |
export const deviceEnquire = function (callback) { |
|
10 |
const matchDesktop = { |
|
11 |
match: () => { |
|
12 |
callback && callback(DEVICE_TYPE.DESKTOP) |
|
13 |
} |
|
14 |
} |
|
15 |
|
|
16 |
const matchLablet = { |
|
17 |
match: () => { |
|
18 |
callback && callback(DEVICE_TYPE.TABLET) |
|
19 |
} |
|
20 |
} |
|
21 |
|
|
22 |
const matchMobile = { |
|
23 |
match: () => { |
|
24 |
callback && callback(DEVICE_TYPE.MOBILE) |
|
25 |
} |
|
26 |
} |
|
27 |
|
|
28 |
// screen and (max-width: 1087.99px) |
|
29 |
enquireJs |
|
30 |
.register('screen and (max-width: 576px)', matchMobile) |
|
31 |
.register('screen and (min-width: 576px) and (max-width: 1199px)', matchLablet) |
|
32 |
.register('screen and (min-width: 1200px)', matchDesktop) |
|
33 |
} |