@jump-section/core 1.0.10 → 1.0.12

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.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- 'use strict';var b=Object.defineProperty;var h=Object.getOwnPropertySymbols;var p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable;var c=(i,e,t)=>e in i?b(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t,a=(i,e)=>{for(var t in e||(e={}))p.call(e,t)&&c(i,t,e[t]);if(h)for(var t of h(e))d.call(e,t)&&c(i,t,e[t]);return i};var s=(i,e,t)=>c(i,typeof e!="symbol"?e+"":e,t);var v=class{constructor(e={}){s(this,"sections",new Map);s(this,"observer",null);s(this,"activeId",null);s(this,"listeners",new Set);s(this,"options");s(this,"handleIntersection",e=>{let t=e.filter(n=>n.isIntersecting);if(t.length>0){let r=t.reduce((o,l)=>o.intersectionRatio>l.intersectionRatio?o:l).target.id;r&&r!==this.activeId&&(this.activeId=r,this.notifyListeners());}});this.options=a({offset:0,behavior:"smooth"},e),this.initObserver();}initObserver(){typeof window!="undefined"&&(this.observer=new IntersectionObserver(this.handleIntersection,{rootMargin:"-20% 0px -60% 0px",threshold:[0,.1,.5,1]}));}registerSection(e,t){t&&(this.sections.set(e,t),this.observer||(this.observer=new IntersectionObserver(this.handleIntersection,{rootMargin:"-10% 0px -80% 0px",threshold:0})),t.id||(t.id=e),this.observer.observe(t));}unregisterSection(e){let t=this.sections.get(e);t&&this.observer&&this.observer.unobserve(t),this.sections.delete(e);}scrollTo(e){let t=this.sections.get(e);if(!t){console.warn(`[ScrollManager] Section with id "${e}" not found. Available sections: ${Array.from(this.sections.keys()).join(", ")}`);return}let{offset:n,behavior:r}=this.options,o=t.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:o+(n||0),behavior:r||"smooth"});}onActiveChange(e){return this.listeners.add(e),e(this.activeId),()=>this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>e(this.activeId));}destroy(){this.observer&&this.observer.disconnect(),this.sections.clear(),this.listeners.clear();}};exports.ScrollManager=v;
1
+ 'use strict';var d=Object.defineProperty;var h=Object.getOwnPropertySymbols;var p=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable;var c=(i,e,t)=>e in i?d(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t,a=(i,e)=>{for(var t in e||(e={}))p.call(e,t)&&c(i,t,e[t]);if(h)for(var t of h(e))b.call(e,t)&&c(i,t,e[t]);return i};var s=(i,e,t)=>c(i,typeof e!="symbol"?e+"":e,t);var v=class{constructor(e={}){s(this,"sections",new Map);s(this,"observer",null);s(this,"activeId",null);s(this,"listeners",new Set);s(this,"options");s(this,"handleIntersection",e=>{let t=e.filter(r=>r.isIntersecting);if(t.length>0){let n=t.reduce((o,l)=>o.intersectionRatio>l.intersectionRatio?o:l).target.id;n&&n!==this.activeId&&(this.activeId=n,this.notifyListeners());}});this.options=a({offset:0,behavior:"smooth"},e),this.initObserver();}initObserver(){typeof window!="undefined"&&(this.observer=new IntersectionObserver(this.handleIntersection,{rootMargin:"-20% 0px -60% 0px",threshold:[0,.1,.5,1]}));}registerSection(e,t){typeof window!="undefined"&&t&&(this.sections.set(e,t),this.observer||(this.observer=new IntersectionObserver(this.handleIntersection,{rootMargin:"-10% 0px -80% 0px",threshold:0})),t.id||(t.id=e),this.observer.observe(t));}unregisterSection(e){let t=this.sections.get(e);t&&this.observer&&this.observer.unobserve(t),this.sections.delete(e);}scrollTo(e){if(typeof window=="undefined")return;let t=this.sections.get(e);if(!t){console.warn(`[ScrollManager] Section with id "${e}" not found. Available sections: ${Array.from(this.sections.keys()).join(", ")}`);return}let{offset:r,behavior:n}=this.options,o=t.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:o+(r||0),behavior:n||"smooth"});}onActiveChange(e){return this.listeners.add(e),e(this.activeId),()=>this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>e(this.activeId));}destroy(){this.observer&&this.observer.disconnect(),this.sections.clear(),this.listeners.clear();}};exports.ScrollManager=v;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var b=Object.defineProperty;var h=Object.getOwnPropertySymbols;var p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable;var c=(i,e,t)=>e in i?b(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t,a=(i,e)=>{for(var t in e||(e={}))p.call(e,t)&&c(i,t,e[t]);if(h)for(var t of h(e))d.call(e,t)&&c(i,t,e[t]);return i};var s=(i,e,t)=>c(i,typeof e!="symbol"?e+"":e,t);var v=class{constructor(e={}){s(this,"sections",new Map);s(this,"observer",null);s(this,"activeId",null);s(this,"listeners",new Set);s(this,"options");s(this,"handleIntersection",e=>{let t=e.filter(n=>n.isIntersecting);if(t.length>0){let r=t.reduce((o,l)=>o.intersectionRatio>l.intersectionRatio?o:l).target.id;r&&r!==this.activeId&&(this.activeId=r,this.notifyListeners());}});this.options=a({offset:0,behavior:"smooth"},e),this.initObserver();}initObserver(){typeof window!="undefined"&&(this.observer=new IntersectionObserver(this.handleIntersection,{rootMargin:"-20% 0px -60% 0px",threshold:[0,.1,.5,1]}));}registerSection(e,t){t&&(this.sections.set(e,t),this.observer||(this.observer=new IntersectionObserver(this.handleIntersection,{rootMargin:"-10% 0px -80% 0px",threshold:0})),t.id||(t.id=e),this.observer.observe(t));}unregisterSection(e){let t=this.sections.get(e);t&&this.observer&&this.observer.unobserve(t),this.sections.delete(e);}scrollTo(e){let t=this.sections.get(e);if(!t){console.warn(`[ScrollManager] Section with id "${e}" not found. Available sections: ${Array.from(this.sections.keys()).join(", ")}`);return}let{offset:n,behavior:r}=this.options,o=t.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:o+(n||0),behavior:r||"smooth"});}onActiveChange(e){return this.listeners.add(e),e(this.activeId),()=>this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>e(this.activeId));}destroy(){this.observer&&this.observer.disconnect(),this.sections.clear(),this.listeners.clear();}};export{v as ScrollManager};
1
+ var d=Object.defineProperty;var h=Object.getOwnPropertySymbols;var p=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable;var c=(i,e,t)=>e in i?d(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t,a=(i,e)=>{for(var t in e||(e={}))p.call(e,t)&&c(i,t,e[t]);if(h)for(var t of h(e))b.call(e,t)&&c(i,t,e[t]);return i};var s=(i,e,t)=>c(i,typeof e!="symbol"?e+"":e,t);var v=class{constructor(e={}){s(this,"sections",new Map);s(this,"observer",null);s(this,"activeId",null);s(this,"listeners",new Set);s(this,"options");s(this,"handleIntersection",e=>{let t=e.filter(r=>r.isIntersecting);if(t.length>0){let n=t.reduce((o,l)=>o.intersectionRatio>l.intersectionRatio?o:l).target.id;n&&n!==this.activeId&&(this.activeId=n,this.notifyListeners());}});this.options=a({offset:0,behavior:"smooth"},e),this.initObserver();}initObserver(){typeof window!="undefined"&&(this.observer=new IntersectionObserver(this.handleIntersection,{rootMargin:"-20% 0px -60% 0px",threshold:[0,.1,.5,1]}));}registerSection(e,t){typeof window!="undefined"&&t&&(this.sections.set(e,t),this.observer||(this.observer=new IntersectionObserver(this.handleIntersection,{rootMargin:"-10% 0px -80% 0px",threshold:0})),t.id||(t.id=e),this.observer.observe(t));}unregisterSection(e){let t=this.sections.get(e);t&&this.observer&&this.observer.unobserve(t),this.sections.delete(e);}scrollTo(e){if(typeof window=="undefined")return;let t=this.sections.get(e);if(!t){console.warn(`[ScrollManager] Section with id "${e}" not found. Available sections: ${Array.from(this.sections.keys()).join(", ")}`);return}let{offset:r,behavior:n}=this.options,o=t.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:o+(r||0),behavior:n||"smooth"});}onActiveChange(e){return this.listeners.add(e),e(this.activeId),()=>this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>e(this.activeId));}destroy(){this.observer&&this.observer.disconnect(),this.sections.clear(),this.listeners.clear();}};export{v as ScrollManager};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jump-section/core",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Core scroll management library for jump-section",
5
5
  "keywords": [
6
6
  "scroll",