Compare commits

...

12 Commits

Author SHA1 Message Date
c7b9374169 2.0.22 2022-05-01 20:07:30 +02:00
dfe189ff1c fix(core): update 2022-05-01 20:07:29 +02:00
b777508b7a 2.0.21 2022-05-01 19:24:16 +02:00
52664d8ea1 fix(core): update 2022-05-01 19:24:16 +02:00
7bad85a1fa 2.0.20 2022-05-01 16:42:37 +02:00
e5056a7be3 fix(core): update 2022-05-01 16:42:37 +02:00
989d4d35d2 2.0.19 2022-04-22 10:39:35 +02:00
c5e75419b3 fix(core): update 2022-04-22 10:39:34 +02:00
ca52d06c60 2.0.18 2022-04-22 09:37:50 +02:00
d33366c487 fix(core): update 2022-04-22 09:37:50 +02:00
3bc5e1d0e2 2.0.17 2022-04-22 09:25:10 +02:00
96a88112dc fix(core): update 2022-04-22 09:25:10 +02:00
6 changed files with 55 additions and 31 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@designestate/dees-domtools", "name": "@designestate/dees-domtools",
"version": "2.0.16", "version": "2.0.22",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@designestate/dees-domtools", "name": "@designestate/dees-domtools",
"version": "2.0.16", "version": "2.0.22",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@apiglobal/typedrequest": "^2.0.3", "@apiglobal/typedrequest": "^2.0.3",

View File

@ -1,6 +1,6 @@
{ {
"name": "@designestate/dees-domtools", "name": "@designestate/dees-domtools",
"version": "2.0.16", "version": "2.0.22",
"private": false, "private": false,
"description": "tools to simplify complex css structures", "description": "tools to simplify complex css structures",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@designestate/dees-domtools',
version: '2.0.22',
description: 'tools to simplify complex css structures'
}

View File

@ -146,6 +146,23 @@ export class DomTools {
this.elements.headElement.appendChild(styleElement); this.elements.headElement.appendChild(styleElement);
} }
/**
* allows to set global styles
* @param stylesText the css text you want to set
*/
public async setExternalScript(scriptLinkArg: string) {
await this.domReady.promise;
const done = plugins.smartpromise.defer();
const script = document.createElement('script')
script.src = scriptLinkArg;
script.addEventListener('load', function() {
done.resolve();
});
const parentNode = document.head || document.body;
parentNode.append(script);
await done.promise;
}
/** /**
* allows setting external css files * allows setting external css files
* @param cssLinkArg a url to an external stylesheet * @param cssLinkArg a url to an external stylesheet

View File

@ -144,6 +144,16 @@ export class Keyboard {
return subject; return subject;
} }
public triggerKeyPress(keysArg: Key[]) {
for (const key of keysArg) {
this.pressedKeys.add(key);
}
this.checkMatchingKeyboardSubjects();
for (const key of keysArg) {
this.pressedKeys.delete(key);
}
}
public startListening() { public startListening() {
this.domNode.addEventListener('keydown', this.handleKeyDown); this.domNode.addEventListener('keydown', this.handleKeyDown);
this.domNode.addEventListener('keyup', this.handleKeyUp); this.domNode.addEventListener('keyup', this.handleKeyUp);
@ -162,22 +172,25 @@ export class Keyboard {
private handleKeyDown = (event: KeyboardEvent) => { private handleKeyDown = (event: KeyboardEvent) => {
this.pressedKeys.add(event.keyCode); this.pressedKeys.add(event.keyCode);
this.checkMatchingKeyboardSubjects(event);
};
private checkMatchingKeyboardSubjects(payloadArg?) {
this.mapCombosToHandlers.forEach((subjectArg, keysArg) => { this.mapCombosToHandlers.forEach((subjectArg, keysArg) => {
if (this.areAllKeysPressed(keysArg)) { if (this.areAllKeysPressed(keysArg)) {
subjectArg.next(event); subjectArg.next(payloadArg);
} }
}); });
}; }
private handleKeyUp = (event: KeyboardEvent) => { private handleKeyUp = (event: KeyboardEvent) => {
this.pressedKeys.delete(event.keyCode); this.pressedKeys.delete(event.keyCode);
}; };
private areAllKeysPressed(combo: number[]) { private areAllKeysPressed(keysArg: Key[]) {
let result = true; let result = true;
combo.forEach((key) => { keysArg.forEach((key) => {
if (!this.pressedKeys.has(key)) { if (!this.pressedKeys.has(key)) {
result = false; result = false;
} }

View File

@ -6,30 +6,16 @@ import { css, unsafeCSS } from 'lit';
* changes scrollbar styles to be consistent across OS borders * changes scrollbar styles to be consistent across OS borders
*/ */
export const scrollBarStyles: string = (() => { export const scrollBarStyles: string = (() => {
const returnStyles = const returnStylesOld = navigator.userAgent.indexOf('Mac OS X') === -1 ? css``.cssText : ``;
navigator.userAgent.indexOf('Mac OS X') === -1 const returnStyles = css`
? css` /* width */
/* width */ ::-webkit-scrollbar {
::-webkit-scrollbar { width: 0px;
width: 6px; }
} body {
scrollbar-width: none;
/* Track */ }
::-webkit-scrollbar-track { `.cssText;
background: #111;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #666;
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #777;
}
`.cssText
: ``;
return returnStyles; return returnStyles;
})(); })();