Make clicking outside the settings popup dismiss it

This commit is contained in:
Patrick Walton 2017-09-06 18:39:14 -07:00
parent 2166f9fa07
commit 3378fb3447
2 changed files with 7 additions and 4 deletions

View File

@ -49,9 +49,7 @@
<div class="pf-arrow-box"></div>
</div>
<button id="pf-settings-button" type="button" class="btn btn-outline-secondary"
aria-expanded="false" aria-controls="#pf-settings">
{{octicon "gear"}}
</button>
aria-expanded="false" aria-controls="#pf-settings">{{octicon "gear"}}</button>
</div>
<div class="rounded py-1 px-3 mr-3" id="pf-fps-label">0 ms</div>
</div>

View File

@ -60,12 +60,17 @@ export abstract class DemoAppController<View extends PathfinderDemoView> extends
this.settingsButton = document.getElementById('pf-settings-button') as HTMLButtonElement;
this.settingsCloseButton = document.getElementById('pf-settings-close-button') as
HTMLButtonElement;
this.settingsButton.addEventListener('click', () => {
this.settingsButton.addEventListener('click', event => {
event.stopPropagation();
this.settingsCard.classList.toggle('pf-invisible');
}, false);
this.settingsCloseButton.addEventListener('click', () => {
this.settingsCard.classList.add('pf-invisible');
}, false);
document.body.addEventListener('click', () => {
this.settingsCard.classList.add('pf-invisible');
}, false);
this.filePickerElement = document.getElementById('pf-file-select') as
(HTMLInputElement | null);