mirror of
https://github.com/zotero/zotero.git
synced 2026-10-07 02:58:09 +00:00
Deprecate windowed-list _getItemPosition() in favor of getRowPosition()
This commit is contained in:
parent
e9ffaf0457
commit
0a7e4d26b4
2 changed files with 22 additions and 18 deletions
|
|
@ -1557,7 +1557,7 @@ class VirtualizedTable extends React.Component {
|
|||
let currentIndex = -1;
|
||||
let nextIndex = -1;
|
||||
for (let index of headerIndices) {
|
||||
if (this._jsWindow._getItemPosition(index) <= scrollTop) {
|
||||
if (this._jsWindow.getRowPosition(index) <= scrollTop) {
|
||||
currentIndex = index;
|
||||
}
|
||||
else {
|
||||
|
|
@ -1568,7 +1568,7 @@ class VirtualizedTable extends React.Component {
|
|||
// Show the pinned copy only once the header row has scrolled up past the top edge of
|
||||
// the view
|
||||
let stuck = currentIndex != -1
|
||||
&& scrollTop > this._jsWindow._getItemPosition(currentIndex);
|
||||
&& scrollTop > this._jsWindow.getRowPosition(currentIndex);
|
||||
if (!stuck) {
|
||||
clip.style.display = 'none';
|
||||
this._stickyHeaderIndex = null;
|
||||
|
|
@ -1597,7 +1597,7 @@ class VirtualizedTable extends React.Component {
|
|||
// Push the pinned header up as the next section's header approaches the top
|
||||
let translateY = 0;
|
||||
if (nextIndex != -1) {
|
||||
let nextTop = this._jsWindow._getItemPosition(nextIndex) - scrollTop;
|
||||
let nextTop = this._jsWindow.getRowPosition(nextIndex) - scrollTop;
|
||||
if (nextTop < this._rowHeight) {
|
||||
translateY = nextTop - this._rowHeight;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ module.exports = class {
|
|||
if (!this._renderedRows.has(index)) return;
|
||||
let oldElem = this._renderedRows.get(index);
|
||||
let elem = this.renderItem(index, oldElem);
|
||||
elem.style.top = this._getItemPosition(index) + "px";
|
||||
elem.style.top = this.getRowPosition(index) + "px";
|
||||
elem.style.position = "absolute";
|
||||
if (elem == oldElem) return;
|
||||
this.innerElem.replaceChild(elem, this._renderedRows.get(index));
|
||||
|
|
@ -138,7 +138,7 @@ module.exports = class {
|
|||
for (let index = startIndex; index < stopIndex; index++) {
|
||||
if (this._renderedRows.has(index)) continue;
|
||||
let elem = renderItem(index);
|
||||
elem.style.top = this._getItemPosition(index) + "px";
|
||||
elem.style.top = this.getRowPosition(index) + "px";
|
||||
elem.style.position = "absolute";
|
||||
innerElem.appendChild(elem);
|
||||
this._renderedRows.set(index, elem);
|
||||
|
|
@ -213,8 +213,8 @@ module.exports = class {
|
|||
const height = this.getWindowHeight();
|
||||
|
||||
index = Math.max(0, Math.min(index, itemCount - 1));
|
||||
let startPosition = this._getItemPosition(index);
|
||||
let endPosition = this._getItemPosition(index + 1);
|
||||
let startPosition = this.getRowPosition(index);
|
||||
let endPosition = this.getRowPosition(index + 1);
|
||||
if (startPosition - topOffset < scrollOffset) {
|
||||
this.scrollTo(startPosition - topOffset);
|
||||
}
|
||||
|
|
@ -223,16 +223,6 @@ module.exports = class {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the position of the top of a row relative to the top of the list
|
||||
*
|
||||
* @param {Integer} index
|
||||
* @return {Integer}
|
||||
*/
|
||||
getRowPosition(index) {
|
||||
return this._getItemPosition(index);
|
||||
}
|
||||
|
||||
getFirstVisibleRow() {
|
||||
const idx = this._binarySearchOffsets(this._rowOffsets, this.scrollOffset, true);
|
||||
const [offsetIdx, offset] = this._rowOffsets[idx];
|
||||
|
|
@ -246,12 +236,26 @@ module.exports = class {
|
|||
return Math.max(1, offsetIdx + Math.ceil(((this.scrollOffset + height + 1) - offset) / this.itemHeight)) - 1;
|
||||
}
|
||||
|
||||
_getItemPosition = (index) => {
|
||||
/**
|
||||
* Return the position of the top of a row relative to the top of the list
|
||||
*
|
||||
* @param {Integer} index
|
||||
* @return {Integer}
|
||||
*/
|
||||
getRowPosition = (index) => {
|
||||
const idx = this._binarySearchOffsets(this._rowOffsets, index);
|
||||
const [offsetIdx, offset] = this._rowOffsets[idx];
|
||||
return offset + (this.itemHeight * (index - offsetIdx));
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated Use getRowPosition()
|
||||
*/
|
||||
_getItemPosition = (index) => {
|
||||
Zotero.warn('windowed-list _getItemPosition() is deprecated -- use getRowPosition()');
|
||||
return this.getRowPosition(index);
|
||||
};
|
||||
|
||||
_getRangeToRender() {
|
||||
const { overscanCount, scrollDirection } = this;
|
||||
const itemCount = this._getItemCount();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue