Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "Make ScrollablePane._sortStickies change elements only when needed.",
"type": "patch"
}
],
"packageName": "office-ui-fabric-react",
"email": "s@warmsea.net"
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,23 @@ export class ScrollablePaneBase extends BaseComponent<IScrollablePaneProps, {}>
const bOffset = this._calculateOffsetParent(b.root);
return aOffset - bOffset;
});
while (container.lastChild) {
container.removeChild(container.lastChild);
// Get number of elements that is already in order.
let elementsInOrder = 0;
while (elementsInOrder < container.children.length && elementsInOrder < stickyArr.length) {
if (container.children[elementsInOrder] === stickyArr[elementsInOrder].content) {
++elementsInOrder;
} else {
break;
}
}
// Remove elements that is not in order if exist.
for (let i = container.children.length - 1; i >= elementsInOrder; --i) {
container.removeChild(container.children[i]);
}
// Append further elements if needed.
for (let i = elementsInOrder; i < stickyArr.length; ++i) {
container.appendChild(stickyArr[i].content);
}
stickyArr.forEach((sticky) => {
container.appendChild(sticky.content);
});
}

private _calculateOffsetParent(ele: HTMLElement): number {
Expand Down