Add a slight timeout to update the fontSmoothing pref (#407)

This seems like a bug with chrome/electron where the devicePixelRatio
value doesn't update right away. It's probably in the event loop, so
adding a short timeout should solve this problem.
This commit is contained in:
Mike 2016-07-26 11:46:23 -06:00 committed by Guillermo Rauch
parent 063045a829
commit 7e889dd509

View file

@ -60,14 +60,18 @@ export function resetFontSize () {
} }
export function setFontSmoothing () { export function setFontSmoothing () {
const devicePixelRatio = window.devicePixelRatio; return (dispatch) => {
const fontSmoothing = devicePixelRatio < 2 setTimeout(() => {
? 'subpixel-antialiased' const devicePixelRatio = window.devicePixelRatio;
: 'antialiased'; const fontSmoothing = devicePixelRatio < 2
? 'subpixel-antialiased'
: 'antialiased';
return { dispatch({
type: UI_FONT_SMOOTHING_SET, type: UI_FONT_SMOOTHING_SET,
fontSmoothing fontSmoothing
});
}, 100);
}; };
} }