Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no highlight while dragging out of canvas #177

Merged
merged 5 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 20 additions & 28 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
<script type="module" src="index.ts"></script>
</head>
<body>
<header id="header">
<p class="no-highlight">Peirce My Heart</p>
<header id="header" class="no-highlight">
<p>Peirce My Heart</p>
</header>
<div id="sidebar">
<div id="sidebar" class="no-highlight">
<div class="row">
<button type="button" title="Selection Mode" class="modeButton">
<i class="fa fa-mouse-pointer" aria-hidden="true"></i>
Expand All @@ -40,40 +40,35 @@
</button>
</div>
</div>
<div id="toolbar">
<div id="toolbar" class="no-highlight">
<div id="genericTools">
<div class="toolSetting">
<p id="graphString"></p>
</div>
<div class="fileButton">
<div class="toolSetting">
<p class="no-highlight">Theme:</p>
</div>
<select id="theme-select" name="theme-select" data-choose-theme>
<p>Theme:</p>
</div><select id="theme-select" name="theme-select" data-choose-theme>
<option value="">Nature</option>
<option value="Wireframe">Wireframe</option>
<option value="Dark-Wireframe">Dark-Wireframe</option>
<option value="vs-code">VS-Code</option>
</select>
<button type="button" onclick="saveMode()" title="Save File" class="modeButton">
</select><button type="button" onclick="saveMode()" title="Save File" class="modeButton">
<i class="fa fa-floppy-o" aria-hidden="true"></i>
</button>
<button type="button" onclick="loadMode()" title="Load File" class="modeButton">
</button><button type="button" onclick="loadMode()" title="Load File" class="modeButton">
<i class="fa fa-arrow-circle-o-up" aria-hidden="true"></i>
</button>
</div>
</div>
</div>
<div id="subBar">
<div id="subBar" class="no-highlight">
<div id="cutTools">
<div class="toolSetting">
<p class="no-highlight">Show Guidelines:</p>
<p>Show Guidelines:</p>
<input id="showRect" type="checkbox" title="Show Rect"/>
</div>
<div class="toolSetting">
<p class="no-highlight">Cut Mode:</p>
</div>
<div class="toolSetting">
</div><div class="toolSetting">
<p>Cut Mode:</p>
</div><div class="toolSetting">
<select id="mode" name="guideSelector">
<option value="inscribed">Inscribed</option>
<option value="circumscribed">Circumscribed</option>
Expand All @@ -82,17 +77,14 @@
</div>
<div id="atomTools">
<div class="toolSetting">
<p class="no-highlight">Current Atom:</p>
</div>
<div class="toolSetting">
<p class="no-highlight" id="atomDisplay"></p>
</div>
<div class="toolSetting">
<p class="no-highlight">Show Current Bounding Box</p>
<p>Current Atom:</p>
</div><div class="toolSetting">
<p id="atomDisplay"></p>
</div><div class="toolSetting">
<p>Show Current Bounding Box</p>
<input id="atomBox" type="checkbox" title="Show atomBox"/>
</div>
<div class="toolSetting">
<p class="no-highlight">Show All Bounding Boxes</p>
</div><div class="toolSetting">
<p>Show All Bounding Boxes</p>
<input id="atomBoxes" type="checkbox" title="Show atomBoxes"/>
</div>
</div>
Expand Down
35 changes: 35 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ ctx.font = "35pt arial";
const cutDisplay = <HTMLParagraphElement>document.getElementById("graphString");
const cutTools = <HTMLParagraphElement>document.getElementById("cutTools");
const atomTools = <HTMLParagraphElement>document.getElementById("atomTools");
const header = document.getElementById("header");
const sideBar = document.getElementById("sidebar");
const toolBar = document.getElementById("toolbar");
const subBar = document.getElementById("subBar");
window.addEventListener("keydown", keyDownHandler);
canvas.addEventListener("mousedown", mouseDownHandler);
canvas.addEventListener("mousemove", mouseMoveHandler);
Expand Down Expand Up @@ -59,6 +63,37 @@ declare global {
}
}

//Add no-highlight class only when mouse is pressed on a div to ensure that elements in the div are
//not highlighted any other time

header?.addEventListener("mousedown", () => {
header.classList.remove("no-highlight");
});
header?.addEventListener("mouseleave", () => {
header.classList.add("no-highlight");
});

toolBar?.addEventListener("mousedown", () => {
toolBar.classList.remove("no-highlight");
});
toolBar?.addEventListener("mouseleave", () => {
toolBar.classList.add("no-highlight");
});

subBar?.addEventListener("mousedown", () => {
subBar.classList.remove("no-highlight");
});
subBar?.addEventListener("mouseleave", () => {
subBar.classList.add("no-highlight");
});

sideBar?.addEventListener("mousedown", () => {
sideBar.classList.remove("no-highlight");
});
sideBar?.addEventListener("mouseleave", () => {
sideBar.classList.add("no-highlight");
});
AnushaTiwari5 marked this conversation as resolved.
Show resolved Hide resolved

//Active mode button stays pressed down until another mode button is clicked
const modeButtons = document.querySelectorAll(".modeButton");
modeButtons.forEach(button => {
Expand Down