Commit 3f8454dab368a5929f435b93db73013e17fbe703
simplify preview switch logic (don't do instant changes)
Matt McKegg committed on 10/28/2017, 6:54:33 AMParent: c8278cc719a12db5a2a110402e4c30516a93e788
Files changed
lib/observe-link-hover.js | changed |
modules/app/link-preview.js | changed |
lib/observe-link-hover.js | ||
---|---|---|
@@ -17,15 +17,11 @@ | ||
17 | 17 | root.addEventListener('mouseleave', (ev) => { |
18 | 18 | target.set(false) |
19 | 19 | }) |
20 | 20 | |
21 | - var active = Value(false) | |
22 | - | |
23 | - var result = Sustained(Sustained(target, 50), delay || 500, (v) => { | |
24 | - // immediately switch to new hover (with 50 ms delay) if there is a current hover in place | |
25 | - return v === undefined || (active() && v && v !== result()) | |
21 | + var result = Sustained(target, delay || 500, (v) => { | |
22 | + return v === undefined | |
26 | 23 | }) |
27 | 24 | |
28 | 25 | result.cancel = () => target.set(undefined) |
29 | - result.active = active | |
30 | 26 | return result |
31 | 27 | } |
modules/app/link-preview.js | ||
---|---|---|
@@ -15,9 +15,8 @@ | ||
15 | 15 | var i18n = api.intl.sync.i18n |
16 | 16 | return nest('app.linkPreview', function (container, delay) { |
17 | 17 | var currentHover = ObserveLinkHover(container, 500) |
18 | 18 | var previewElement = Value() |
19 | - previewElement(currentHover.active.set) | |
20 | 19 | |
21 | 20 | currentHover(element => { |
22 | 21 | var href = element && element.getAttribute('href') |
23 | 22 | var preview = null |
Built with git-ssb-web