aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utils.ts')
-rw-r--r--src/Utils.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Utils.ts b/src/Utils.ts
index 4b892aa70..f6ab434a8 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -337,4 +337,17 @@ export default function smoothScroll(duration: number, element: HTMLElement, to:
}
};
animateScroll();
+}
+export function addStyleSheet(styleType: string = "text/css") {
+ let style = document.createElement("style");
+ style.type = styleType;
+ var sheets = document.head.appendChild(style);
+ return (sheets as any).sheet;
+}
+export function addStyleSheetRule(sheet: any, selector: any, css: any) {
+ var propText = typeof css === "string" ? css : Object.keys(css).map(p => p + ":" + (p === "content" ? "'" + css[p] + "'" : css[p])).join(";");
+ return sheet.insertRule("." + selector + "{" + propText + "}", sheet.cssRules.length);
+}
+export function removeStyleSheetRule(sheet: any, rule: number) {
+ sheet.removeRule(rule);
} \ No newline at end of file