Commit 47f88c71eec1667f35848253793375e28d250237
preview: immediately switch to new hover if preview is currently visible
Matt McKegg committed on 10/18/2017, 2:08:11 AMParent: fd15190d894f51e76a7c0fd5f53b0db037f171b8
Files changed
lib/observe-link-hover.js | changed |
main-window.js | changed |
lib/observe-link-hover.js | ||
---|---|---|
@@ -17,8 +17,15 @@ | ||
17 | 17 | root.addEventListener('mouseleave', (ev) => { |
18 | 18 | target.set(false) |
19 | 19 | }) |
20 | 20 | |
21 | - var result = Sustained(target, delay || 500, (v) => v === undefined) | |
21 | + var active = Value(false) | |
22 | + | |
23 | + var result = Sustained(target, delay || 500, (v) => { | |
24 | + // immediately switch to new hover if there is a current hover in place | |
25 | + return v === undefined || (active() && v && v !== result()) | |
26 | + }) | |
27 | + | |
22 | 28 | result.cancel = () => target.set(undefined) |
29 | + result.active = active | |
23 | 30 | return result |
24 | 31 | } |
main-window.js | ||
---|---|---|
@@ -129,8 +129,9 @@ | ||
129 | 129 | ]) |
130 | 130 | |
131 | 131 | var currentHover = ObserveLinkHover(container, 500) |
132 | 132 | var previewElement = Value() |
133 | + previewElement(currentHover.active.set) | |
133 | 134 | |
134 | 135 | currentHover(element => { |
135 | 136 | var href = element && element.getAttribute('href') |
136 | 137 | var preview = null |
Built with git-ssb-web