aboutsummaryrefslogtreecommitdiffstats
path: root/static/modules/k1c.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/modules/k1c.js')
-rw-r--r--static/modules/k1c.js27
1 files changed, 3 insertions, 24 deletions
diff --git a/static/modules/k1c.js b/static/modules/k1c.js
index 261ef4d..6b41a01 100644
--- a/static/modules/k1c.js
+++ b/static/modules/k1c.js
@@ -15,10 +15,11 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import { offline } from "../offline.js";
+import { hold } from "../hold.js";
-// Holding the stop for this long fires it: fast in an emergency, but a
+// Holding the stop (hold.js's 800 ms) fires it: fast in an emergency, but a
// stray touch on an always-on tablet cannot kill a print.
-const HOLD_MS = 800;
+const armHold = (btn) => hold(btn, () => emergencyStop(btn));
const STATES = {
printing: ["Printing", "good"],
@@ -64,28 +65,6 @@ async function emergencyStop(btn) {
}, 4000);
}
-// Press and hold: the ring fills over HOLD_MS, releasing early cancels.
-function armHold(btn) {
- let timer = null;
- const cancel = () => {
- clearTimeout(timer);
- timer = null;
- btn.classList.remove("holding");
- };
- btn.addEventListener("pointerdown", (e) => {
- e.preventDefault();
- btn.setPointerCapture(e.pointerId);
- btn.classList.add("holding");
- timer = setTimeout(() => {
- cancel();
- emergencyStop(btn);
- }, HOLD_MS);
- });
- btn.addEventListener("pointerup", cancel);
- btn.addEventListener("pointercancel", cancel);
- btn.style.setProperty("--hold", `${HOLD_MS}ms`);
-}
-
// The dashboard's running slot: file, percent, time left, layer and
// temperatures, the press-and-hold stop and a progress bar. Wide slots show
// the slicer thumbnail in place of the icon (deck.css container query).