Skip to content

Commit

Permalink
add an overlay to terminal in room to prevent input mode when touch o…
Browse files Browse the repository at this point in the history
…n terminal
  • Loading branch information
qnkhuat committed Aug 31, 2021
1 parent 6142334 commit 337698b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion client/src/components/StreamPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const StreamPreview: FC<Props> = ({ title, wsUrl, streamerID, nViewers, startedT
Data: "",
});
setTimeout(() => {
ws.send(payload);
utils.sendWhenConnected(ws, payload);
}, 100);
})

Expand Down
9 changes: 4 additions & 5 deletions client/src/components/Terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as message from "../types/message";
import * as buffer from "../lib/buffer";
import * as pako from "pako";


interface Winsize {
Rows: number;
Cols: number;
Expand All @@ -21,7 +20,6 @@ interface Props {
className?: string;
}


const Terminal: React.FC<Props> = ({ msgManager, width = -1, height = -1, delay = 0, className = ""}: Props) => {
const termRef = useRef<Xterm>(null);
const divRef = useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -101,6 +99,7 @@ const Terminal: React.FC<Props> = ({ msgManager, width = -1, height = -1, delay
return (
<div className={`relative ${className} overflow-hidden`}
style={{width: width!, height: height!}}>
<div className="overlay bg-transparent absolute top-0 left-0 z-10 w-full h-full"></div>
<div ref={divRef}
className="divref absolute top-1/2 left-1/2 origin-top-left transform -translate-x-1/2 -translate-y-1/2 overflow-hidden">
<Xterm
Expand All @@ -118,8 +117,8 @@ class WriteManager {

queue: message.Wrapper[] = [];
writeCB: (arr:Uint8Array) => void;
winsizeCB: (ws:Winsize) => void
delay: number; // in milliseconds
winsizeCB: (ws:Winsize) => void;
delay: number; // in milliseconds

constructor(writeCB: (arr: Uint8Array) => void, winsizeCB: (ws: Winsize) => void, delay: number = 0) {
this.writeCB = writeCB;
Expand Down Expand Up @@ -212,7 +211,7 @@ class WriteManager {
let msgArrayString: string[] = JSON.parse(buffer.ab2str(data));

let msgArray: message.Wrapper[] = [];
msgArrayString.forEach((msgString: string, i) => {
msgArrayString.forEach((msgString: string) => {
// re-compute the offset of this message with respect to the render time
let msg: message.Wrapper = JSON.parse(window.atob(msgString));
msg.Delay = msg.Delay - blockDelayTime;
Expand Down
8 changes: 4 additions & 4 deletions client/src/pages/[room]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,18 +302,18 @@ class Room extends React.Component<Props, State> {
<div id="terminal-view" className="relative"
onMouseMove={() => this.flashTitle()}>
{this.state.roomInfo?.Status == RoomStatus.Streaming &&
<div id="info" className={`relative w-full ${this.state.mouseMove ? "visible" : "hidden"}`}>
<div id="info" className={`relative w-full ${this.state.mouseMove ? "visible" : "hidden"} z-20`}>

<div className={`top-0 left-0 w-full absolute z-10 px-4 py-2 bg-opacity-80 bg-gray-800 `}>
<div className={`top-0 left-0 w-full absolute z-20 px-4 py-2 bg-opacity-80 bg-gray-800 `}>
<p className="text-2xl">{this.state.roomInfo!.Title}</p>
<p className="text-md">@{this.state.roomInfo!.StreamerID}</p>
</div>

<div id="info-uptime" className={`p-1 bg-red-400 rounded absolute top-4 right-4 z-10`}>
<div id="info-uptime" className={`p-1 bg-red-400 rounded absolute top-4 right-4 z-20`}>
<Uptime className="text-md text-white font-semibold" startTime={new Date(this.state.roomInfo!.StartedTime)} />
</div>

<div id="info-nviewers" className="p-1 bg-gray-400 rounded absolute top-4 right-24 z-10">
<div id="info-nviewers" className="p-1 bg-gray-400 rounded absolute top-4 right-24 z-20">
<p className="text-md text-whtie font-semibold"><PersonIcon/> {this.state.roomInfo!.NViewers}</p>
</div>

Expand Down

1 comment on commit 337698b

@vercel
Copy link

@vercel vercel bot commented on 337698b Aug 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.