@fluid-topics/ft-infinite-scroll 1.1.78 → 1.1.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -74,9 +74,11 @@ class FtInfiniteScroll extends FtLitElement {
74
74
  this.lastScrollTop = currentScrollTop;
75
75
  if (this.scrolledToTarget) {
76
76
  this.restoreScrollIfNeeded(ignoreThisScrollEvent ? 0 : scrollDiff);
77
- const scrollRestorationElement = this.searchFirstVisibleItem(currentScrollTop, this.itemsContainer.children);
78
- this.scrollRestorationItem = scrollRestorationElement ? +scrollRestorationElement.getAttribute("data-item-index") : undefined;
79
- this.scrollRestorationOffset = currentScrollTop - this.getOffset(scrollRestorationElement);
77
+ if (!ignoreThisScrollEvent || this.scrollRestorationItem == null) {
78
+ const newScrollRestorationElement = this.searchFirstVisibleItem(currentScrollTop, this.itemsContainer.children);
79
+ this.scrollRestorationItem = newScrollRestorationElement ? +newScrollRestorationElement.getAttribute("data-item-index") : undefined;
80
+ this.scrollRestorationOffset = currentScrollTop - this.getOffset(newScrollRestorationElement);
81
+ }
80
82
  }
81
83
  };
82
84
  this.restoreScrollIfNeeded = (scrollCorrection = 0) => {
@@ -28,7 +28,7 @@
28
28
  display: flow-root;
29
29
  min-height: ${I.itemContainerMinHeight};
30
30
  }
31
- `;var h=function(r,e,t,s){var i=arguments.length,l=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(r,e,t,s);else for(var d=r.length-1;d>=0;d--)(o=r[d])&&(l=(i<3?o(l):i>3?o(e,t,l):o(e,t))||l);return i>3&&l&&Object.defineProperty(e,t,l),l},T=class extends CustomEvent{constructor(e,t){super("visible-items-change",{detail:{visibleIndexes:e,visibleItems:t}})}},S=class extends Event{constructor(){super("scrolled-to-target")}},G=r=>(r??[])[(r??[]).length-1],n=class extends c.FtLitElement{constructor(){super(...arguments),this.items=[],this.renderItem=()=>m.html``,this.getItemKey=(e,t)=>`${t} - ${JSON.stringify(e)}`,this.internalScroll=!1,this.renderBeforeFirst=1,this.renderAfterLast=1,this.ensureScrollToTarget=!1,this.visibleItems=[],this.scrolledToTarget=!1,this.scrolling=!1,this.renderApprovalTimeouts=[],this.renderedIndexes=new Set,this.scrollDebouncer=new c.Debouncer(5),this.scrollDoneDebouncer=new c.Debouncer(10),this.onVisibilityChange=e=>{let t=new Set(this.visibleItems),s=new Set;for(let i of e){let l=+i.target.getAttribute("data-item-index");i.intersectionRect.height>0?(t.add(l),s.add(l)):s.has(l)||t.delete(l)}this.visibleItems=[...t].sort((i,l)=>i-l)},this.intersectionObserver=new IntersectionObserver(this.onVisibilityChange),this.scrollingDebouncer=new c.Debouncer(50),this.ignoreNextScrollEvent=!1,this.scrollListener=()=>{var e;let t=this.ignoreNextScrollEvent;this.ignoreNextScrollEvent=!1,t||(this.scrolling=!0,this.scrollingDebouncer.run(()=>this.scrolling=!1));let s=this.scrollable.scrollTop,i=s-((e=this.lastScrollTop)!==null&&e!==void 0?e:0);if(this.lastScrollTop=s,this.scrolledToTarget){this.restoreScrollIfNeeded(t?0:i);let l=this.searchFirstVisibleItem(s,this.itemsContainer.children);this.scrollRestorationItem=l?+l.getAttribute("data-item-index"):void 0,this.scrollRestorationOffset=s-this.getOffset(l)}},this.restoreScrollIfNeeded=(e=0)=>{var t;let s=this.scrollable.scrollHeight,i=s-((t=this.lastScrollHeight)!==null&&t!==void 0?t:s);if(this.lastScrollHeight=s,i!==0&&this.scrollRestorationItem!=null&&this.scrollRestorationOffset!=null&&this.scrolledToTarget){let l=this.getItem(this.scrollRestorationItem),o=this.getOffset(l),d=(0,c.minmax)(this.scrollRestorationItem===0?-o:1,this.scrollRestorationOffset,l.clientHeight-1),b=o+d+e-this.scrollable.scrollTop;(Math.abs(i-b)<4||Math.abs(b)>5)&&(this.ignoreNextScrollEvent=!0,this.scrollable.scrollTop+=b)}},this._shouldRestoreScroll=!1,this.scrollAdjustment=()=>{this.restoreScrollIfNeeded(),this.shouldRestoreScroll&&requestAnimationFrame(this.scrollAdjustment)},this.onMutation=()=>{for(let e of this.itemsContainer.children)this.intersectionObserver.observe(e)},this.mutationObserver=new MutationObserver(this.onMutation),this.resetVisibleItemsDebouncer=new c.Debouncer(10)}get scrollable(){var e;return(e=this._scrollable)!==null&&e!==void 0?e:document.body}set scrollable(e){var t,s,i,l;this._scrollable!==e&&((t=this._scrollable)===null||t===void 0||t.removeEventListener("scroll",this.scrollListener),this._scrollable&&this.initialOverflowAnchorValue&&(this.scrollable.style.overflowAnchor=this.initialOverflowAnchorValue),this._scrollable=e,(s=this._scrollable)===null||s===void 0||s.addEventListener("scroll",this.scrollListener),this.lastScrollTop=(i=this._scrollable)===null||i===void 0?void 0:i.scrollTop,this.lastScrollHeight=(l=this._scrollable)===null||l===void 0?void 0:l.scrollHeight,this._scrollable&&(this.initialOverflowAnchorValue=getComputedStyle(this._scrollable).overflowAnchor,this._scrollable.style.overflowAnchor="none"))}render(){return m.html`
31
+ `;var h=function(r,e,t,s){var i=arguments.length,l=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(r,e,t,s);else for(var d=r.length-1;d>=0;d--)(o=r[d])&&(l=(i<3?o(l):i>3?o(e,t,l):o(e,t))||l);return i>3&&l&&Object.defineProperty(e,t,l),l},T=class extends CustomEvent{constructor(e,t){super("visible-items-change",{detail:{visibleIndexes:e,visibleItems:t}})}},S=class extends Event{constructor(){super("scrolled-to-target")}},G=r=>(r??[])[(r??[]).length-1],n=class extends c.FtLitElement{constructor(){super(...arguments),this.items=[],this.renderItem=()=>m.html``,this.getItemKey=(e,t)=>`${t} - ${JSON.stringify(e)}`,this.internalScroll=!1,this.renderBeforeFirst=1,this.renderAfterLast=1,this.ensureScrollToTarget=!1,this.visibleItems=[],this.scrolledToTarget=!1,this.scrolling=!1,this.renderApprovalTimeouts=[],this.renderedIndexes=new Set,this.scrollDebouncer=new c.Debouncer(5),this.scrollDoneDebouncer=new c.Debouncer(10),this.onVisibilityChange=e=>{let t=new Set(this.visibleItems),s=new Set;for(let i of e){let l=+i.target.getAttribute("data-item-index");i.intersectionRect.height>0?(t.add(l),s.add(l)):s.has(l)||t.delete(l)}this.visibleItems=[...t].sort((i,l)=>i-l)},this.intersectionObserver=new IntersectionObserver(this.onVisibilityChange),this.scrollingDebouncer=new c.Debouncer(50),this.ignoreNextScrollEvent=!1,this.scrollListener=()=>{var e;let t=this.ignoreNextScrollEvent;this.ignoreNextScrollEvent=!1,t||(this.scrolling=!0,this.scrollingDebouncer.run(()=>this.scrolling=!1));let s=this.scrollable.scrollTop,i=s-((e=this.lastScrollTop)!==null&&e!==void 0?e:0);if(this.lastScrollTop=s,this.scrolledToTarget&&(this.restoreScrollIfNeeded(t?0:i),!t||this.scrollRestorationItem==null)){let l=this.searchFirstVisibleItem(s,this.itemsContainer.children);this.scrollRestorationItem=l?+l.getAttribute("data-item-index"):void 0,this.scrollRestorationOffset=s-this.getOffset(l)}},this.restoreScrollIfNeeded=(e=0)=>{var t;let s=this.scrollable.scrollHeight,i=s-((t=this.lastScrollHeight)!==null&&t!==void 0?t:s);if(this.lastScrollHeight=s,i!==0&&this.scrollRestorationItem!=null&&this.scrollRestorationOffset!=null&&this.scrolledToTarget){let l=this.getItem(this.scrollRestorationItem),o=this.getOffset(l),d=(0,c.minmax)(this.scrollRestorationItem===0?-o:1,this.scrollRestorationOffset,l.clientHeight-1),b=o+d+e-this.scrollable.scrollTop;(Math.abs(i-b)<4||Math.abs(b)>5)&&(this.ignoreNextScrollEvent=!0,this.scrollable.scrollTop+=b)}},this._shouldRestoreScroll=!1,this.scrollAdjustment=()=>{this.restoreScrollIfNeeded(),this.shouldRestoreScroll&&requestAnimationFrame(this.scrollAdjustment)},this.onMutation=()=>{for(let e of this.itemsContainer.children)this.intersectionObserver.observe(e)},this.mutationObserver=new MutationObserver(this.onMutation),this.resetVisibleItemsDebouncer=new c.Debouncer(10)}get scrollable(){var e;return(e=this._scrollable)!==null&&e!==void 0?e:document.body}set scrollable(e){var t,s,i,l;this._scrollable!==e&&((t=this._scrollable)===null||t===void 0||t.removeEventListener("scroll",this.scrollListener),this._scrollable&&this.initialOverflowAnchorValue&&(this.scrollable.style.overflowAnchor=this.initialOverflowAnchorValue),this._scrollable=e,(s=this._scrollable)===null||s===void 0||s.addEventListener("scroll",this.scrollListener),this.lastScrollTop=(i=this._scrollable)===null||i===void 0?void 0:i.scrollTop,this.lastScrollHeight=(l=this._scrollable)===null||l===void 0?void 0:l.scrollHeight,this._scrollable&&(this.initialOverflowAnchorValue=getComputedStyle(this._scrollable).overflowAnchor,this._scrollable.style.overflowAnchor="none"))}render(){return m.html`
32
32
  <div class="items-container ${this.internalScroll?"scrollable":""}"
33
33
  tabindex="-1"
34
34
  @find-scrollable-parent=${this.findScrollableParent}>
@@ -69,7 +69,7 @@ Also for action icons.`,l.colorGray200),contentGlobalSubtle:r.extend("--ft-conte
69
69
  display: flow-root;
70
70
  min-height: ${en.itemContainerMinHeight};
71
71
  }
72
- `;var F=function(o,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(o,e,t,n);else for(var d=o.length-1;d>=0;d--)(s=o[d])&&(a=(i<3?s(a):i>3?s(e,t,a):s(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},tn=class extends CustomEvent{constructor(e,t){super("visible-items-change",{detail:{visibleIndexes:e,visibleItems:t}})}},rn=class extends Event{constructor(){super("scrolled-to-target")}},fl=o=>(o??[])[(o??[]).length-1],M=class extends te{constructor(){super(...arguments),this.items=[],this.renderItem=()=>mt``,this.getItemKey=(e,t)=>`${t} - ${JSON.stringify(e)}`,this.internalScroll=!1,this.renderBeforeFirst=1,this.renderAfterLast=1,this.ensureScrollToTarget=!1,this.visibleItems=[],this.scrolledToTarget=!1,this.scrolling=!1,this.renderApprovalTimeouts=[],this.renderedIndexes=new Set,this.scrollDebouncer=new Q(5),this.scrollDoneDebouncer=new Q(10),this.onVisibilityChange=e=>{let t=new Set(this.visibleItems),n=new Set;for(let i of e){let a=+i.target.getAttribute("data-item-index");i.intersectionRect.height>0?(t.add(a),n.add(a)):n.has(a)||t.delete(a)}this.visibleItems=[...t].sort((i,a)=>i-a)},this.intersectionObserver=new IntersectionObserver(this.onVisibilityChange),this.scrollingDebouncer=new Q(50),this.ignoreNextScrollEvent=!1,this.scrollListener=()=>{var e;let t=this.ignoreNextScrollEvent;this.ignoreNextScrollEvent=!1,t||(this.scrolling=!0,this.scrollingDebouncer.run(()=>this.scrolling=!1));let n=this.scrollable.scrollTop,i=n-((e=this.lastScrollTop)!==null&&e!==void 0?e:0);if(this.lastScrollTop=n,this.scrolledToTarget){this.restoreScrollIfNeeded(t?0:i);let a=this.searchFirstVisibleItem(n,this.itemsContainer.children);this.scrollRestorationItem=a?+a.getAttribute("data-item-index"):void 0,this.scrollRestorationOffset=n-this.getOffset(a)}},this.restoreScrollIfNeeded=(e=0)=>{var t;let n=this.scrollable.scrollHeight,i=n-((t=this.lastScrollHeight)!==null&&t!==void 0?t:n);if(this.lastScrollHeight=n,i!==0&&this.scrollRestorationItem!=null&&this.scrollRestorationOffset!=null&&this.scrolledToTarget){let a=this.getItem(this.scrollRestorationItem),s=this.getOffset(a),d=Hr(this.scrollRestorationItem===0?-s:1,this.scrollRestorationOffset,a.clientHeight-1),c=s+d+e-this.scrollable.scrollTop;(Math.abs(i-c)<4||Math.abs(c)>5)&&(this.ignoreNextScrollEvent=!0,this.scrollable.scrollTop+=c)}},this._shouldRestoreScroll=!1,this.scrollAdjustment=()=>{this.restoreScrollIfNeeded(),this.shouldRestoreScroll&&requestAnimationFrame(this.scrollAdjustment)},this.onMutation=()=>{for(let e of this.itemsContainer.children)this.intersectionObserver.observe(e)},this.mutationObserver=new MutationObserver(this.onMutation),this.resetVisibleItemsDebouncer=new Q(10)}get scrollable(){var e;return(e=this._scrollable)!==null&&e!==void 0?e:document.body}set scrollable(e){var t,n,i,a;this._scrollable!==e&&((t=this._scrollable)===null||t===void 0||t.removeEventListener("scroll",this.scrollListener),this._scrollable&&this.initialOverflowAnchorValue&&(this.scrollable.style.overflowAnchor=this.initialOverflowAnchorValue),this._scrollable=e,(n=this._scrollable)===null||n===void 0||n.addEventListener("scroll",this.scrollListener),this.lastScrollTop=(i=this._scrollable)===null||i===void 0?void 0:i.scrollTop,this.lastScrollHeight=(a=this._scrollable)===null||a===void 0?void 0:a.scrollHeight,this._scrollable&&(this.initialOverflowAnchorValue=getComputedStyle(this._scrollable).overflowAnchor,this._scrollable.style.overflowAnchor="none"))}render(){return mt`
72
+ `;var F=function(o,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(o,e,t,n);else for(var d=o.length-1;d>=0;d--)(s=o[d])&&(a=(i<3?s(a):i>3?s(e,t,a):s(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},tn=class extends CustomEvent{constructor(e,t){super("visible-items-change",{detail:{visibleIndexes:e,visibleItems:t}})}},rn=class extends Event{constructor(){super("scrolled-to-target")}},fl=o=>(o??[])[(o??[]).length-1],M=class extends te{constructor(){super(...arguments),this.items=[],this.renderItem=()=>mt``,this.getItemKey=(e,t)=>`${t} - ${JSON.stringify(e)}`,this.internalScroll=!1,this.renderBeforeFirst=1,this.renderAfterLast=1,this.ensureScrollToTarget=!1,this.visibleItems=[],this.scrolledToTarget=!1,this.scrolling=!1,this.renderApprovalTimeouts=[],this.renderedIndexes=new Set,this.scrollDebouncer=new Q(5),this.scrollDoneDebouncer=new Q(10),this.onVisibilityChange=e=>{let t=new Set(this.visibleItems),n=new Set;for(let i of e){let a=+i.target.getAttribute("data-item-index");i.intersectionRect.height>0?(t.add(a),n.add(a)):n.has(a)||t.delete(a)}this.visibleItems=[...t].sort((i,a)=>i-a)},this.intersectionObserver=new IntersectionObserver(this.onVisibilityChange),this.scrollingDebouncer=new Q(50),this.ignoreNextScrollEvent=!1,this.scrollListener=()=>{var e;let t=this.ignoreNextScrollEvent;this.ignoreNextScrollEvent=!1,t||(this.scrolling=!0,this.scrollingDebouncer.run(()=>this.scrolling=!1));let n=this.scrollable.scrollTop,i=n-((e=this.lastScrollTop)!==null&&e!==void 0?e:0);if(this.lastScrollTop=n,this.scrolledToTarget&&(this.restoreScrollIfNeeded(t?0:i),!t||this.scrollRestorationItem==null)){let a=this.searchFirstVisibleItem(n,this.itemsContainer.children);this.scrollRestorationItem=a?+a.getAttribute("data-item-index"):void 0,this.scrollRestorationOffset=n-this.getOffset(a)}},this.restoreScrollIfNeeded=(e=0)=>{var t;let n=this.scrollable.scrollHeight,i=n-((t=this.lastScrollHeight)!==null&&t!==void 0?t:n);if(this.lastScrollHeight=n,i!==0&&this.scrollRestorationItem!=null&&this.scrollRestorationOffset!=null&&this.scrolledToTarget){let a=this.getItem(this.scrollRestorationItem),s=this.getOffset(a),d=Hr(this.scrollRestorationItem===0?-s:1,this.scrollRestorationOffset,a.clientHeight-1),c=s+d+e-this.scrollable.scrollTop;(Math.abs(i-c)<4||Math.abs(c)>5)&&(this.ignoreNextScrollEvent=!0,this.scrollable.scrollTop+=c)}},this._shouldRestoreScroll=!1,this.scrollAdjustment=()=>{this.restoreScrollIfNeeded(),this.shouldRestoreScroll&&requestAnimationFrame(this.scrollAdjustment)},this.onMutation=()=>{for(let e of this.itemsContainer.children)this.intersectionObserver.observe(e)},this.mutationObserver=new MutationObserver(this.onMutation),this.resetVisibleItemsDebouncer=new Q(10)}get scrollable(){var e;return(e=this._scrollable)!==null&&e!==void 0?e:document.body}set scrollable(e){var t,n,i,a;this._scrollable!==e&&((t=this._scrollable)===null||t===void 0||t.removeEventListener("scroll",this.scrollListener),this._scrollable&&this.initialOverflowAnchorValue&&(this.scrollable.style.overflowAnchor=this.initialOverflowAnchorValue),this._scrollable=e,(n=this._scrollable)===null||n===void 0||n.addEventListener("scroll",this.scrollListener),this.lastScrollTop=(i=this._scrollable)===null||i===void 0?void 0:i.scrollTop,this.lastScrollHeight=(a=this._scrollable)===null||a===void 0?void 0:a.scrollHeight,this._scrollable&&(this.initialOverflowAnchorValue=getComputedStyle(this._scrollable).overflowAnchor,this._scrollable.style.overflowAnchor="none"))}render(){return mt`
73
73
  <div class="items-container ${this.internalScroll?"scrollable":""}"
74
74
  tabindex="-1"
75
75
  @find-scrollable-parent=${this.findScrollableParent}>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-infinite-scroll",
3
- "version": "1.1.78",
3
+ "version": "1.1.80",
4
4
  "description": "An infinite scroller.",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,8 +19,8 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-wc-utils": "1.1.78",
22
+ "@fluid-topics/ft-wc-utils": "1.1.80",
23
23
  "lit": "3.1.0"
24
24
  },
25
- "gitHead": "b4f44baf8cd02d5ef4ba2fd616f0aa9483a8a027"
25
+ "gitHead": "9454653b9d84c51d905be4956706b7a0ef1aa2f6"
26
26
  }