Commit 3a3732c95a5d34d4a8f506224643609f35c55a5d
hide link preview on scroll
Matt McKegg committed on 11/4/2017, 10:40:59 PMParent: 23e948464d4642d4d44d3dce35cea8d6e944b222
Files changed
modules/app/link-preview.js | changed |
modules/app/link-preview.js | ||
---|---|---|
@@ -13,8 +13,9 @@ | ||
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 | + | |
17 | 18 | var currentHover = ObserveLinkHover(container, (value, lastValue) => { |
18 | 19 | var href = value && value.getAttribute('href') |
19 | 20 | var oldHref = lastValue && lastValue.getAttribute('href') |
20 | 21 | |
@@ -35,9 +36,8 @@ | ||
35 | 36 | |
36 | 37 | if (href) { |
37 | 38 | if (ref.isFeed(href)) { |
38 | 39 | preview = api.profile.html.preview(href) |
39 | - preview.onwheel = previewElement.cancel | |
40 | 40 | } else if (href.includes('://')) { |
41 | 41 | preview = h('ProfilePreview', [ |
42 | 42 | h('section', [ |
43 | 43 | h('strong', [i18n('External Link'), ' ๐']), h('br'), |
@@ -47,8 +47,9 @@ | ||
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | 50 | if (preview) { |
51 | + preview.addEventListener('wheel', previewElement.cancel) | |
51 | 52 | var rect = element.getBoundingClientRect() |
52 | 53 | var width = 510 |
53 | 54 | var maxLeft = window.innerWidth - width |
54 | 55 | var maxTop = window.innerHeight - 100 |
@@ -83,7 +84,10 @@ | ||
83 | 84 | currentHover.cancel() |
84 | 85 | previewElement.set(null) |
85 | 86 | } |
86 | 87 | |
88 | + // hide preview on scroll | |
89 | + container.addEventListener('wheel', previewElement.cancel) | |
90 | + | |
87 | 91 | return previewElement |
88 | 92 | }) |
89 | 93 | } |
Built with git-ssb-web