Skip to content

Commit

Permalink
fix: Error using $q.screen.setSizes() quasarframework#2469
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoenescu committed Aug 26, 2018
1 parent 739cb82 commit 9da4a4d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 8 additions & 0 deletions dev/components/other/screen-plugin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ export default {
'$q.screen.gt.md' (state) {
console.log('watcher $q.screen.gt.md', state)
}
},
mounted () {
this.$q.screen.setSizes({
sm: 300,
md: 500,
lg: 1000,
xl: 2000
})
}
}
</script>
12 changes: 8 additions & 4 deletions src/plugins/screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { isSSR, fromSSR } from './platform.js'
import { listenOpts } from '../utils/event.js'
import debounce from '../utils/debounce.js'

const SIZE_LIST = ['sm', 'md', 'lg', 'xl']

export default {
width: 0,

Expand Down Expand Up @@ -59,8 +61,10 @@ export default {
let updateEvt, updateSizes = {}, updateDebounce

this.setSizes = sizes => {
sizes.forEach(name => {
updateSizes[name] = sizes[name]
SIZE_LIST.forEach(name => {
if (sizes[name]) {
updateSizes[name] = sizes[name]
}
})
}
this.setDebounce = deb => {
Expand All @@ -72,13 +76,13 @@ export default {

// if css props available
if (style.getPropertyValue('--q-size-sm')) {
['sm', 'md', 'lg', 'xl'].forEach(name => {
SIZE_LIST.forEach(name => {
this.sizes[name] = parseInt(style.getPropertyValue(`--q-size-${name}`), 10)
})
}

this.setSizes = sizes => {
['sm', 'md', 'lg', 'xl'].forEach(name => {
SIZE_LIST.forEach(name => {
if (sizes[name]) {
this.sizes[name] = sizes[name]
}
Expand Down

0 comments on commit 9da4a4d

Please sign in to comment.