aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/PresBox.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2020-08-24 11:21:20 -0400
committerbobzel <zzzman@gmail.com>2020-08-24 11:21:20 -0400
commit505ad0d2e2a37795f1877b2319a8ba3a1ce65d28 (patch)
tree3bc61a2edb944ae0083e38244e4b41ea89cdbbf8 /src/client/views/nodes/PresBox.tsx
parent3058388e7d377d874f4460e9fba3f1ba51127cb0 (diff)
cleaned up all library() calls to add icons. fixed import styles. fixed keyboard events for presentation views to trigger when no input box is the target.
Diffstat (limited to 'src/client/views/nodes/PresBox.tsx')
-rw-r--r--src/client/views/nodes/PresBox.tsx33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/client/views/nodes/PresBox.tsx b/src/client/views/nodes/PresBox.tsx
index 050ecfc49..1228a285e 100644
--- a/src/client/views/nodes/PresBox.tsx
+++ b/src/client/views/nodes/PresBox.tsx
@@ -87,14 +87,12 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps, PresBoxSchema>
} else { return undefined; }
}
@computed get isPres(): boolean {
+ document.removeEventListener("keydown", this.keyEvents, true);
if (this.selectedDoc?.type === DocumentType.PRES) {
- document.removeEventListener("keydown", this.keyEvents, true);
document.addEventListener("keydown", this.keyEvents, true);
return true;
- } else {
- document.removeEventListener("keydown", this.keyEvents, true);
- return false;
}
+ return false;
}
@computed get selectedDoc() { return this.selectedDocumentView?.rootDoc; }
@@ -373,7 +371,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps, PresBoxSchema>
if (this.layoutDoc.presStatus === 'auto' && !this.layoutDoc.presLoop) this.layoutDoc.presStatus = "manual";
else if (this.layoutDoc.presLoop) this.startAutoPres(0);
}, duration);
- };
+ }
}
};
this.layoutDoc.presStatus = "auto";
@@ -614,6 +612,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps, PresBoxSchema>
// Key for when the presentaiton is active
@action
keyEvents = (e: KeyboardEvent) => {
+ if (e.target instanceof HTMLInputElement) return;
let handled = false;
const anchorNode = document.activeElement as HTMLDivElement;
if (anchorNode && anchorNode.className?.includes("lm_title")) return;
@@ -629,10 +628,12 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps, PresBoxSchema>
handled = true;
}
} if (e.keyCode === 37 || e.keyCode === 38) { // left(37) / a(65) / up(38) to go back
- this.back(); if (this._presTimer) clearTimeout(this._presTimer);
+ this.back();
+ if (this._presTimer) clearTimeout(this._presTimer);
handled = true;
} if (e.keyCode === 39 || e.keyCode === 40) { // right (39) / d(68) / down(40) to go to next
- this.next(); if (this._presTimer) clearTimeout(this._presTimer);
+ this.next();
+ if (this._presTimer) clearTimeout(this._presTimer);
handled = true;
} if (e.keyCode === 32) { // spacebar to 'present' or autoplay
if (this.layoutDoc.presStatus !== "edit") this.startAutoPres(0);
@@ -640,9 +641,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps, PresBoxSchema>
handled = true;
} if (e.keyCode === 8) { // delete selected items
if (this.layoutDoc.presStatus === "edit") {
- this._selectedArray.forEach((doc, i) => {
- this.removeDocument(doc);
- });
+ this._selectedArray.forEach((doc, i) => this.removeDocument(doc));
this._selectedArray = [];
this._eleArray = [];
this._dragArray = [];
@@ -815,7 +814,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps, PresBoxSchema>
<div className="ribbon-property">
<input className="presBox-input"
type="number" value={transitionSpeed}
- onFocus={() => { document.removeEventListener("keydown", this.keyEvents, true); }}
+ onFocus={() => document.removeEventListener("keydown", this.keyEvents, true)}
onChange={action((e) => this.setTransitionTime(e.target.value))} /> s
</div>
<div className="ribbon-propertyUpDown">
@@ -845,7 +844,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps, PresBoxSchema>
<div className="ribbon-property">
<input className="presBox-input"
type="number" value={duration}
- onFocus={() => { document.removeEventListener("keydown", this.keyEvents, true); }}
+ onFocus={() => document.removeEventListener("keydown", this.keyEvents, true)}
onChange={action((e) => this.setDurationTime(e.target.value))} /> s
</div>
<div className="ribbon-propertyUpDown">
@@ -974,7 +973,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps, PresBoxSchema>
<input className="presBox-input"
style={{ textAlign: 'left', width: 50 }}
type="number" value={NumCast(activeItem.presPinViewX)}
- onFocus={() => { document.removeEventListener("keydown", this.keyEvents, true); }}
+ onFocus={() => document.removeEventListener("keydown", this.keyEvents, true)}
onChange={action((e: React.ChangeEvent<HTMLInputElement>) => { const val = e.target.value; activeItem.presPinViewX = Number(val); })} />
</div>
</div>
@@ -984,7 +983,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps, PresBoxSchema>
<input className="presBox-input"
style={{ textAlign: 'left', width: 50 }}
type="number" value={NumCast(activeItem.presPinViewY)}
- onFocus={() => { document.removeEventListener("keydown", this.keyEvents, true); }}
+ onFocus={() => document.removeEventListener("keydown", this.keyEvents, true)}
onChange={action((e: React.ChangeEvent<HTMLInputElement>) => { const val = e.target.value; activeItem.presPinViewY = Number(val); })} />
</div>
</div>
@@ -994,7 +993,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps, PresBoxSchema>
<input className="presBox-input"
style={{ textAlign: 'left', width: 50 }}
type="number" value={NumCast(activeItem.presPinViewScale)}
- onFocus={() => { document.removeEventListener("keydown", this.keyEvents, true); }}
+ onFocus={() => document.removeEventListener("keydown", this.keyEvents, true)}
onChange={action((e: React.ChangeEvent<HTMLInputElement>) => { const val = e.target.value; activeItem.presPinViewScale = Number(val); })} />
</div>
</div>
@@ -1044,9 +1043,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps, PresBoxSchema>
<div className="ribbon-box">
Slide Title: <br></br>
<input className="ribbon-textInput" placeholder="..." type="text" name="fname"
- onFocus={() => {
- document.removeEventListener("keydown", this.keyEvents, true);
- }}
+ onFocus={() => document.removeEventListener("keydown", this.keyEvents, true)}
onChange={(e) => {
e.stopPropagation();
e.preventDefault();