From d29981868f1004353614a52ac6e16609bbacb046 Mon Sep 17 00:00:00 2001 From: igoradamenko Date: Tue, 17 Apr 2018 12:08:06 +0300 Subject: [PATCH] fix links to comments --- web/app/common/constants.js | 2 +- web/app/components/root/root.jsx | 2 +- web/app/embed.js | 8 ++++++++ web/iframe.html | 11 ++++++++++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/web/app/common/constants.js b/web/app/common/constants.js index 873f893e..8399dcbc 100644 --- a/web/app/common/constants.js +++ b/web/app/common/constants.js @@ -1,4 +1,4 @@ -const BASE_URL = '/'; +const BASE_URL = 'https://remark42.radio-t.com/'; const API_BASE = '/api/v1'; const NODE_ID = 'remark42'; const COUNTER_NODE_CLASSNAME = 'remark42__counter'; diff --git a/web/app/components/root/root.jsx b/web/app/components/root/root.jsx index d8fb78cc..1c5c4a31 100644 --- a/web/app/components/root/root.jsx +++ b/web/app/components/root/root.jsx @@ -66,7 +66,7 @@ export default class Root extends Component { setTimeout(() => { comment.scrollIntoView(); window.scrollTo(window.scrollX, 0); // sometimes smth goes wrong and iframe scrolls; we return it here - }, 1000); + }, 500); } } } diff --git a/web/app/embed.js b/web/app/embed.js index cdeae4d9..1e4ab8e4 100644 --- a/web/app/embed.js +++ b/web/app/embed.js @@ -51,11 +51,19 @@ function init() { window.addEventListener('message', updateIframeHeight); + window.addEventListener('hashchange', postHashToIframe); + + setTimeout(postHashToIframe, 1000); + function updateIframeHeight(event) { try { const data = JSON.parse(event.data); iframe.style.height = `${data.remarkIframeHeight}px`; } catch (e) {} } + + function postHashToIframe() { + iframe.contentWindow.postMessage(JSON.stringify({ hash: location.hash }), '*'); + } } diff --git a/web/iframe.html b/web/iframe.html index 6ac0412d..84e1b613 100644 --- a/web/iframe.html +++ b/web/iframe.html @@ -8,7 +8,6 @@
- +