Skip to content

Commit c025dcb

Browse files
committed
Updated commented lines and removed unnessary console logs of Canvas
1 parent 7c6fa88 commit c025dcb

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

app/src/components/main/Canvas.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@ function Canvas(props: {}): JSX.Element {
3131
//remote cursor data
3232
const [remoteCursors, setRemoteCursors] = useState([]);
3333

34-
// toggle switch
34+
// Toggle switch for live cursor tracking
3535
const [toggleSwitch, setToggleSwitch] = useState(true);
3636

37-
// toggle text
37+
// Toggle button text for live cursor tracking button - on/off
3838
const [toggleText, setToggleText] = useState('off');
3939
const toggleButton = () => {
4040
setToggleText(toggleText === 'on' ? 'off' : 'on');
4141
};
4242

43+
// Prevents lagging and provides smoother user experience got live cursor tracking (milliseconds can be adjusted but 300ms is most optimal)
4344
const debounceSetPosition = debounce((newX, newY) => {
4445
//emit socket event every 300ms when cursor moves
4546
if (userList.length > 1)
@@ -91,10 +92,11 @@ function Canvas(props: {}): JSX.Element {
9192
});
9293
};
9394

94-
console.log('userList:', userList);
95+
// console.log('userList:', userList);
9596
//[{x,y,remoteUserName, isVisible}, {...}, {...}]
96-
console.log('remoteCursors:', remoteCursors);
97+
// console.log('remoteCursors:', remoteCursors);
9798

99+
// Removes the mouse cursor of the user that leaves the collaboration room.
98100
const handleCursorDeleteFromServer = () => {
99101
setRemoteCursors((prevRemoteCursors) =>
100102
prevRemoteCursors.map((cursor) => ({
@@ -104,6 +106,7 @@ function Canvas(props: {}): JSX.Element {
104106
);
105107
};
106108

109+
// Function that will turn on/off socket depending on toggle Switch.
107110
const handleToggleSwitch = () => {
108111
setToggleSwitch(!toggleSwitch);
109112
//checks the state before it's updated so need to check the opposite condition
@@ -133,9 +136,7 @@ function Canvas(props: {}): JSX.Element {
133136
}
134137
};
135138

136-
console.log('Toggle Switch:', toggleSwitch);
137-
138-
//Function to handle the click events.
139+
//Function to handle the multiple click events of the toggle button.
139140
const multipleClicks = () => {
140141
handleToggleSwitch();
141142
toggleButton();
@@ -192,7 +193,6 @@ function Canvas(props: {}): JSX.Element {
192193
childId: childId
193194
});
194195
}
195-
// console.log('emit changeFocusAction event is triggered in canvas');
196196
};
197197

198198
// onClickHandler is responsible for changing the focused component and child component
@@ -325,6 +325,7 @@ function Canvas(props: {}): JSX.Element {
325325
currentComponent.style
326326
);
327327

328+
// Array of colors that color code users as they join the room (In a set order)
328329
const userColors = [
329330
'#FC00BD',
330331
'#D0FC00',
@@ -365,7 +366,6 @@ function Canvas(props: {}): JSX.Element {
365366
</div>
366367
)
367368
)}
368-
369369
<label className="switch">
370370
{userList.length > 1 && (
371371
<button

0 commit comments

Comments
 (0)