const changeset = this._changesets.get(id);
if (!changeset) return;
- changeset.sidebarRelativePosition = state;
- this._updateChangesetStyle(changeset);
+ if (changeset.sidebarRelativePosition !== state) {
+ changeset.sidebarRelativePosition = state;
+ this._updateChangesetStyle(changeset);
+ }
},
getLayerId: function (layer) {
if (!window.IntersectionObserver) return;
let keepInitialLocation = true;
+ let itemsInViewport = $();
changesetIntersectionObserver = new IntersectionObserver((entries) => {
let closestTargetToTop,
const id = $(entry.target).data("changeset")?.id;
if (entry.isIntersecting) {
+ itemsInViewport = itemsInViewport.add(entry.target);
if (id) changesetsLayer.setChangesetSidebarRelativePosition(id, 0);
continue;
+ } else {
+ itemsInViewport = itemsInViewport.not(entry.target);
}
const distanceToTop = entry.rootBounds.top - entry.boundingClientRect.bottom;
const distanceToBottom = entry.boundingClientRect.top - entry.rootBounds.bottom;
- if (id) changesetsLayer.setChangesetSidebarRelativePosition(id, distanceToTop >= 0 ? 1 : -1);
-
if (distanceToTop >= 0 && distanceToTop < closestDistanceToTop) {
closestDistanceToTop = distanceToTop;
closestTargetToTop = entry.target;
}
}
+ itemsInViewport.first().prevAll().each(function () {
+ const id = $(this).data("changeset")?.id;
+ if (id) changesetsLayer.setChangesetSidebarRelativePosition(id, 1);
+ });
+ itemsInViewport.last().nextAll().each(function () {
+ const id = $(this).data("changeset")?.id;
+ if (id) changesetsLayer.setChangesetSidebarRelativePosition(id, -1);
+ });
+
changesetsLayer.reorderChangesets();
if (keepInitialLocation) {