From 501a103a1d380de47d8e188a201a9555c9b2df36 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 24 Mar 2019 07:16:45 -0700 Subject: [PATCH] Make movement of image hover / quote preview with mouse optional; option is `Follow Cursor`. #471, #2245 --- src/General/UI.coffee | 5 ++++- src/config/Config.coffee | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/General/UI.coffee b/src/General/UI.coffee index 388aea7c4..929f85278 100644 --- a/src/General/UI.coffee +++ b/src/General/UI.coffee @@ -309,6 +309,7 @@ dragend = -> $.set "#{@id}.position", @style.cssText hoverstart = ({root, el, latestEvent, endEvents, height, width, cb, noRemove}) -> + rect = root.getBoundingClientRect() o = { root el @@ -322,6 +323,8 @@ hoverstart = ({root, el, latestEvent, endEvents, height, width, cb, noRemove}) - height width noRemove + clientX: (rect.left + rect.right) / 2 + clientY: (rect.top + rect.bottom) / 2 } o.hover = hover.bind o o.hoverend = hoverend.bind o @@ -346,7 +349,7 @@ hover = (e) -> @latestEvent = e height = (@height or @el.offsetHeight) + hoverstart.padding width = (@width or @el.offsetWidth) - {clientX, clientY} = e + {clientX, clientY} = if Conf['Follow Cursor'] then e else @ top = if @isImage Math.max 0, clientY * (@clientHeight - height) / @clientHeight diff --git a/src/config/Config.coffee b/src/config/Config.coffee index fdcc39acc..8b388305c 100644 --- a/src/config/Config.coffee +++ b/src/config/Config.coffee @@ -19,6 +19,10 @@ Config = 'Show a notice at the top of the page when the index is refreshed.' 1 ] + 'Follow Cursor': [ + true + 'Image Hover and Quote Preview move with the mouse cursor.' + ] 'Open Threads in New Tab': [ false 'Make links to threads in the index / <%= meta.name %> catalog open in a new tab.'