refactor toggleGrid to be clearer, only send analytics in response to user action

This commit is contained in:
Ben Wheeler 2020-04-20 13:40:45 -04:00
parent caa7aed291
commit 2762cdf271

View file

@ -729,7 +729,7 @@ export default class UI {
UI.creatTopBarClicky(div, 'go', 'go on', UI.toggleRun); UI.creatTopBarClicky(div, 'go', 'go on', UI.toggleRun);
UI.creatTopBarClicky(div, 'resetall', 'resetall', UI.resetAllSprites); UI.creatTopBarClicky(div, 'resetall', 'resetall', UI.resetAllSprites);
UI.creatTopBarClicky(div, 'full', 'fullscreen', ScratchJr.fullScreen); UI.creatTopBarClicky(div, 'full', 'fullscreen', ScratchJr.fullScreen);
UI.toggleGrid(true); UI.setShowGrid(false);
} }
static resetAllSprites (e) { static resetAllSprites (e) {
@ -756,12 +756,12 @@ export default class UI {
static switchGrid () { static switchGrid () {
ScratchAudio.sndFX('tap.wav'); ScratchAudio.sndFX('tap.wav');
UI.toggleGrid(!Grid.hidden); UI.setShowGrid(Grid.hidden);
iOS.analyticsEvent('editor', Grid.hidden ? 'hide_grid' : 'show_grid');
} }
static toggleGrid (b) { static setShowGrid (b) {
Grid.hide(b); Grid.hide(!b);
iOS.analyticsEvent('editor', Grid.hidden ? 'hide_grid' : 'show_grid');
gn('grid').className = Grid.hidden ? 'gridToggle off' : 'gridToggle on'; gn('grid').className = Grid.hidden ? 'gridToggle off' : 'gridToggle on';
} }