From 45c42540537a494e731b80297f8cb557673aa069 Mon Sep 17 00:00:00 2001 From: Paul Rodwell Date: Thu, 18 Jan 2024 20:04:32 +0000 Subject: [PATCH] align items when starting targeting --- lib/target.coffee | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/target.coffee b/lib/target.coffee index e13e734..f1aa5ff 100644 --- a/lib/target.coffee +++ b/lib/target.coffee @@ -5,6 +5,7 @@ # that highlighting can be immediate when requested. targeting = false +$item = null item = null itemElem = null action = null @@ -28,10 +29,13 @@ bind = -> startTargeting = (e) -> targeting = e.shiftKey - if targeting + if targeting and $item $('.emit').addClass('highlight') if id = item || action $("[data-id=#{id}]").addClass('target') + key = ($page = $(this).parents('.page:first')).data('key') + place = $item.offset().top + $('.page').trigger('align-item', {key, id:item, place}) if itemElem consumed = itemElem.consuming if consumed @@ -79,6 +83,7 @@ leaveItem = (e) -> $('.item, .action').removeClass('target') $('.item').removeClass('consumed') item = null + $item = null itemElem = null