Skip to content

Commit

Permalink
fix: fixes firefox scroll-linked effect issue
Browse files Browse the repository at this point in the history
  • Loading branch information
wickedest committed Apr 23, 2023
1 parent a01cadb commit ce407da
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions src/diff-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function getColors(el) {
function getMergelyContainer({ clazz = '' }) {
const classes = [ 'mergely-editor', clazz ]
return htmlToElement(`\
<div class="${classes.join(' ')}" style="display:flex;height:100%;position:relative;"></div>`);
<div class="${classes.join(' ')}" style="display:flex;height:100%;position:relative;overflow:hidden;"></div>`);
}

function getMarginTemplate({ id }) {
Expand Down
2 changes: 1 addition & 1 deletion src/mergely.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit ce407da

Please sign in to comment.