mirror of
https://github.com/penpot/penpot.git
synced 2025-02-14 19:19:09 -05:00
🐛 Fix auto scroll layers panel in firefox
This commit is contained in:
parent
8d1cd2f56d
commit
a0cc8a06b6
2 changed files with 13 additions and 10 deletions
|
@ -19,6 +19,7 @@
|
||||||
- Remove default font on team change
|
- Remove default font on team change
|
||||||
- Fix github auth without name
|
- Fix github auth without name
|
||||||
- Fix problems with font loading in Firefox 95
|
- Fix problems with font loading in Firefox 95
|
||||||
|
- Fix auto scroll layers in Firefox [Taiga #3531](https://tree.taiga.io/project/penpot/issue/3531)
|
||||||
|
|
||||||
## 1.13.2-beta
|
## 1.13.2-beta
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
Element.prototype.scrollIntoViewIfNeeded = function (centerIfNeeded) {
|
Element.prototype.scrollIntoViewIfNeeded = function (centerIfNeeded) {
|
||||||
centerIfNeeded = arguments.length === 0 ? true : !!centerIfNeeded;
|
centerIfNeeded = arguments.length === 0 ? true : !!centerIfNeeded;
|
||||||
|
|
||||||
var parent = this.parentNode,
|
var parent = this.parentNode;
|
||||||
parentComputedStyle = window.getComputedStyle(parent, null),
|
if (parent) {
|
||||||
|
var parentComputedStyle = window.getComputedStyle(parent, null),
|
||||||
parentBorderTopWidth = parseInt(parentComputedStyle.getPropertyValue('border-top-width')),
|
parentBorderTopWidth = parseInt(parentComputedStyle.getPropertyValue('border-top-width')),
|
||||||
parentBorderLeftWidth = parseInt(parentComputedStyle.getPropertyValue('border-left-width')),
|
parentBorderLeftWidth = parseInt(parentComputedStyle.getPropertyValue('border-left-width')),
|
||||||
overTop = this.offsetTop - parent.offsetTop < parent.scrollTop,
|
overTop = this.offsetTop - parent.offsetTop < parent.scrollTop,
|
||||||
|
@ -13,14 +14,15 @@
|
||||||
overRight = (this.offsetLeft - parent.offsetLeft + this.clientWidth - parentBorderLeftWidth) > (parent.scrollLeft + parent.clientWidth),
|
overRight = (this.offsetLeft - parent.offsetLeft + this.clientWidth - parentBorderLeftWidth) > (parent.scrollLeft + parent.clientWidth),
|
||||||
alignWithTop = overTop && !overBottom;
|
alignWithTop = overTop && !overBottom;
|
||||||
|
|
||||||
if ((overTop || overBottom) && centerIfNeeded) {
|
if ((overTop || overBottom) && centerIfNeeded) {
|
||||||
parent.scrollTop = this.offsetTop - parent.offsetTop - parent.clientHeight / 2 - parentBorderTopWidth + this.clientHeight / 2;
|
parent.scrollTop = this.offsetTop - parent.offsetTop - parent.clientHeight / 2 - parentBorderTopWidth + this.clientHeight / 2;
|
||||||
}
|
}
|
||||||
if ((overLeft || overRight) && centerIfNeeded) {
|
if ((overLeft || overRight) && centerIfNeeded) {
|
||||||
parent.scrollLeft = this.offsetLeft - parent.offsetLeft - parent.clientWidth / 2 - parentBorderLeftWidth + this.clientWidth / 2;
|
parent.scrollLeft = this.offsetLeft - parent.offsetLeft - parent.clientWidth / 2 - parentBorderLeftWidth + this.clientWidth / 2;
|
||||||
}
|
}
|
||||||
if ((overTop || overBottom || overLeft || overRight) && !centerIfNeeded) {
|
if ((overTop || overBottom || overLeft || overRight) && !centerIfNeeded) {
|
||||||
this.scrollIntoView(alignWithTop);
|
this.scrollIntoView(alignWithTop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue