From 91dce1895fe39e336f958a0956b932f63f1d4b92 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 29 Mar 2018 11:36:54 +0200 Subject: [PATCH] Cleanup --- scripts/Application.ts | 5 +---- scripts/SideBar.ts | 5 +++-- scripts/Utils.ts | 10 +--------- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/scripts/Application.ts b/scripts/Application.ts index 9576511c..4d569723 100644 --- a/scripts/Application.ts +++ b/scripts/Application.ts @@ -207,9 +207,6 @@ export class Application { } emit(eventName: string) { - document.dispatchEvent(new Event(eventName, { - "bubbles": true, - "cancelable": true - })) + document.dispatchEvent(new Event(eventName)) } } \ No newline at end of file diff --git a/scripts/SideBar.ts b/scripts/SideBar.ts index 33dd4823..6b5ee703 100644 --- a/scripts/SideBar.ts +++ b/scripts/SideBar.ts @@ -1,4 +1,5 @@ import { TouchController } from "./TouchController" +import { Diff } from "./Diff" export class SideBar { element: HTMLElement @@ -20,11 +21,11 @@ export class SideBar { } show() { - this.element.classList.add("sidebar-visible") + Diff.mutations.queue(() => this.element.classList.add("sidebar-visible")) } hide() { - this.element.classList.remove("sidebar-visible") + Diff.mutations.queue(() => this.element.classList.remove("sidebar-visible")) } toggle() { diff --git a/scripts/Utils.ts b/scripts/Utils.ts index 9eeaef9f..8546907d 100644 --- a/scripts/Utils.ts +++ b/scripts/Utils.ts @@ -15,15 +15,7 @@ export function plural(count: number, singular: string): string { } export function canUseWebP(): boolean { - let canvas = document.createElement("canvas") - - if(!!(canvas.getContext && canvas.getContext("2d"))) { - // WebP representation possible - return canvas.toDataURL("image/webp").indexOf("data:image/webp") === 0 - } else { - // In very old browsers (IE 8) canvas is not supported - return false - } + return document.createElement("canvas").toDataURL("image/webp").indexOf("data:image/webp") === 0 } export function swapElements(a: Node, b: Node) {