Files
kuboard-press/.vuepress/grid/utils/init-rwd.js
huanqing.shao cfc8a2df67 grid
2019-10-04 09:58:52 +08:00

24 lines
594 B
JavaScript

import mediaQueryString from './media-query-string'
import isUndefined from './is-undefined'
export default {
props: {
rwd: Object
},
methods: {
bindMediaQueries (callback) {
if (!isUndefined(this.rwd)) {
Object.keys(this.rwd).forEach(breakpoint => {
const mediaQuery = window.matchMedia(mediaQueryString({
approach: this.config.approach,
query: this.config.breakpoints[breakpoint]
}))
const property = this.rwd[breakpoint]
callback(mediaQuery, property)
})
}
}
}
}