Commit 4f2f50a77ef55ab8e505ad02c47746b3cab34157
link-preview: faster disappear time, faster switching time
Matt McKegg committed on 11/3/2017, 9:07:21 PMParent: 02b8eb670ca5703df29be0edc856fb4e91b20511
Files changed
modules/app/link-preview.js | changed |
modules/app/link-preview.js | ||
---|---|---|
@@ -13,9 +13,21 @@ | ||
13 | 13 | |
14 | 14 | exports.create = function (api) { |
15 | 15 | var i18n = api.intl.sync.i18n |
16 | 16 | return nest('app.linkPreview', function (container, delay) { |
17 | - var currentHover = ObserveLinkHover(container, 500) | |
17 | + var currentHover = ObserveLinkHover(container, (value, lastValue) => { | |
18 | + var href = value && value.getAttribute('href') | |
19 | + var oldHref = lastValue && lastValue.getAttribute('href') | |
20 | + | |
21 | + var delay = 500 | |
22 | + if (href && oldHref) { | |
23 | + delay = 100 | |
24 | + } else if (!value) { | |
25 | + delay = 200 | |
26 | + } | |
27 | + | |
28 | + return delay | |
29 | + }) | |
18 | 30 | var previewElement = Value() |
19 | 31 | |
20 | 32 | currentHover(element => { |
21 | 33 | var href = element && element.getAttribute('href') |
Built with git-ssb-web