diff --git a/src/diff-view.js b/src/diff-view.js index 435f4fb..816464e 100644 --- a/src/diff-view.js +++ b/src/diff-view.js @@ -290,11 +290,6 @@ CodeMirrorDiffView.prototype.bind = function(container) { className: container.className }; const el = dom.getMergelyContainer({ clazz: container.className }); - // const found = document.getElementById(container.id); - // if (!found) { - // console.error(`Failed to find mergely: #${container.id}`); - // return; - // } const computedStyle = window.getComputedStyle(container); if (!computedStyle.height || computedStyle.height === '0px') { throw new Error( @@ -640,7 +635,10 @@ CodeMirrorDiffView.prototype._scrolling = function({ side }) { const scroller = this.editor[side].getScrollerElement(); const { top } = scroller.getBoundingClientRect(); let height; - if (true || this.midway == undefined) { + if (scroller.offsetParent === null) { + return; + } + if (this.midway == undefined) { height = scroller.clientHeight - (scroller.offsetHeight - scroller.offsetParent.offsetHeight); this.midway = (height / 2.0 + top).toFixed(2); diff --git a/src/dom.js b/src/dom.js index 891b477..9f69c4a 100644 --- a/src/dom.js +++ b/src/dom.js @@ -67,7 +67,7 @@ function getColors(el) { function getMergelyContainer({ clazz = '' }) { const classes = [ 'mergely-editor', clazz ] return htmlToElement(`\ -
`); +
`); } function getMarginTemplate({ id }) { diff --git a/src/mergely.js b/src/mergely.js index a50baa2..9d2c6f0 100644 --- a/src/mergely.js +++ b/src/mergely.js @@ -186,7 +186,7 @@ class Mergely { diff() { if (this._options._debug) { - trace('api#diff', side); + trace('api#diff'); } const lhs_text = this.get('lhs'); const rhs_text = this.get('rhs');