Skip to content

Commit

Permalink
Implement media query listener for device pixel ratio changes
Browse files Browse the repository at this point in the history
It should help in #450 case.
  • Loading branch information
abe33 committed Mar 6, 2016
1 parent 033279b commit 54780a4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lib/minimap-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,12 @@ export default class MinimapElement {
Why? Currently, The style element will be removed first, and then re-added
and the `change` event has not be triggered in the process.
*/
return this.subscriptions.add(atom.styles.onDidAddStyleElement(() => {
this.subscriptions.add(atom.styles.onDidAddStyleElement(() => {
this.invalidateDOMStylesCache()
this.requestForcedUpdate()
}))

this.subscriptions.add(this.subscribeToMediaQuery())
}

/**
Expand Down Expand Up @@ -1064,6 +1066,24 @@ export default class MinimapElement {
}
}

/**
* Subscribes to a media query for device pixel ratio changes and forces
* a repaint when it occurs.
*
* @return {Disposable} a disposable to remove the media query listener
* @access private
*/
subscribeToMediaQuery () {
const query = 'screen and (-webkit-min-device-pixel-ratio: 1.5)'
const mediaQuery = window.matchMedia(query)
const mediaListener = (e) => { this.requestForcedUpdate() }
mediaQuery.addListener(mediaListener)

return new Disposable(() => {
mediaQuery.removeListener(mediaListener)
})
}

// ######## #### ########
// ## ## ## ## ## ##
// ## ## #### ## ##
Expand Down

0 comments on commit 54780a4

Please sign in to comment.