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 () {
const devicePixelRatio = window.devicePixelRatio;
const fontSmoothing = devicePixelRatio < 2
? 'subpixel-antialiased'
: 'antialiased';
return (dispatch) => {
setTimeout(() => {
const devicePixelRatio = window.devicePixelRatio;
const fontSmoothing = devicePixelRatio < 2
? 'subpixel-antialiased'
: 'antialiased';
return {
type: UI_FONT_SMOOTHING_SET,
fontSmoothing
dispatch({
type: UI_FONT_SMOOTHING_SET,
fontSmoothing
});
}, 100);
};
}