From b61e59b778da188b9c6a6e7377425c373ae153a1 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 14 Apr 2021 00:44:43 +0100 Subject: [PATCH] js: Break out ungrab_clicked Signed-off-by: Ian Jackson --- templates/script.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/templates/script.ts b/templates/script.ts index ee78263f..990d809d 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -869,6 +869,12 @@ function grab_clicked(clicked: PieceId[]) { api_piece(wresting ? 'wrest' : 'grab', piece,p, { }); } } +function ungrab_clicked(clicked: PieceId[]) { + for (let tpiece of clicked) { + let tp = pieces[tpiece]!; + do_ungrab(tpiece,tp); + } +} function mouse_clicked_one(piece: PieceId): MouseFindClicked { let p = pieces[piece]!; @@ -1008,10 +1014,7 @@ function drag_mousedown(e : MouseEvent, shifted: boolean) { drag_pieces = []; if (held == us) { if (shifted) { - for (let tpiece of clicked) { - let tp = pieces[tpiece]!; - do_ungrab(tpiece,tp); - } + ungrab_clicked(clicked); return; } drag_start_prepare(DRAGGING.MAYBE_UNGRAB); -- 2.30.2