remove useless code from scroll to parent action

This commit is contained in:
igoradamenko
2018-05-12 14:57:25 +03:00
parent 757fcc3fd4
commit 30650cc047
3 changed files with 1 additions and 14 deletions
-1
View File
@@ -1 +0,0 @@
export default msg => window.parent.postMessage(JSON.stringify(msg), '*');
+1 -9
View File
@@ -3,7 +3,6 @@ import { h, Component } from 'preact';
import api from 'common/api';
import { API_BASE, BASE_URL, COMMENT_NODE_CLASSNAME_PREFIX } from 'common/constants';
import { url } from 'common/settings';
import postMessage from 'common/post-message';
import store from 'common/store';
import Input from 'components/input';
@@ -185,18 +184,11 @@ export default class Comment extends Component {
scrollToParent(e) {
const { data: { pid } } = this.props;
const hash = `#${COMMENT_NODE_CLASSNAME_PREFIX}${pid}`;
e.preventDefault();
// reset old hash
postMessage({ hash: '' });
const parentCommentNode = document.getElementById(`${COMMENT_NODE_CLASSNAME_PREFIX}${pid}`);
// set new hash
postMessage({ hash });
// try to scroll into view
const parentCommentNode = document.querySelector(hash);
if (parentCommentNode) {
parentCommentNode.scrollIntoView();
}
-4
View File
@@ -61,10 +61,6 @@ function init() {
if (data.remarkIframeHeight) {
iframe.style.height = `${data.remarkIframeHeight}px`;
}
if (data.hash) {
window.location.hash = data.hash;
}
} catch (e) {}
}