@eric-emg/symphiq-components 1.2.107 → 1.2.108

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.
@@ -24149,12 +24149,24 @@ class FloatingTocComponent {
24149
24149
  scrollToSection(sectionId) {
24150
24150
  const element = document.getElementById(`section-${sectionId}`);
24151
24151
  if (element) {
24152
- const elementPosition = element.getBoundingClientRect().top + window.scrollY;
24153
- const offsetPosition = elementPosition - this.HEADER_OFFSET;
24154
- window.scrollTo({
24155
- top: offsetPosition,
24156
- behavior: 'smooth'
24157
- });
24152
+ if (this.embedded && this.scrollElement) {
24153
+ const scrollTop = this.scrollElement.scrollTop;
24154
+ const containerRect = this.scrollElement.getBoundingClientRect();
24155
+ const elementRect = element.getBoundingClientRect();
24156
+ const offsetPosition = scrollTop + (elementRect.top - containerRect.top) - this.HEADER_OFFSET - this.parentHeaderOffset;
24157
+ this.scrollElement.scrollTo({
24158
+ top: offsetPosition,
24159
+ behavior: 'smooth'
24160
+ });
24161
+ }
24162
+ else {
24163
+ const elementPosition = element.getBoundingClientRect().top + window.scrollY;
24164
+ const offsetPosition = elementPosition - this.HEADER_OFFSET;
24165
+ window.scrollTo({
24166
+ top: offsetPosition,
24167
+ behavior: 'smooth'
24168
+ });
24169
+ }
24158
24170
  }
24159
24171
  if (!this.isPinned()) {
24160
24172
  this.isHovered.set(false);
@@ -24163,19 +24175,36 @@ class FloatingTocComponent {
24163
24175
  scrollToSubsection(subsectionId) {
24164
24176
  const element = document.getElementById(`subsection-${subsectionId}`);
24165
24177
  if (element) {
24166
- const elementPosition = element.getBoundingClientRect().top + window.scrollY;
24167
- const offsetPosition = elementPosition - this.HEADER_OFFSET;
24168
- window.scrollTo({
24169
- top: offsetPosition,
24170
- behavior: 'smooth'
24171
- });
24178
+ if (this.embedded && this.scrollElement) {
24179
+ const scrollTop = this.scrollElement.scrollTop;
24180
+ const containerRect = this.scrollElement.getBoundingClientRect();
24181
+ const elementRect = element.getBoundingClientRect();
24182
+ const offsetPosition = scrollTop + (elementRect.top - containerRect.top) - this.HEADER_OFFSET - this.parentHeaderOffset;
24183
+ this.scrollElement.scrollTo({
24184
+ top: offsetPosition,
24185
+ behavior: 'smooth'
24186
+ });
24187
+ }
24188
+ else {
24189
+ const elementPosition = element.getBoundingClientRect().top + window.scrollY;
24190
+ const offsetPosition = elementPosition - this.HEADER_OFFSET;
24191
+ window.scrollTo({
24192
+ top: offsetPosition,
24193
+ behavior: 'smooth'
24194
+ });
24195
+ }
24172
24196
  }
24173
24197
  if (!this.isPinned()) {
24174
24198
  this.isHovered.set(false);
24175
24199
  }
24176
24200
  }
24177
24201
  scrollToTop() {
24178
- window.scrollTo({ top: 0, behavior: 'smooth' });
24202
+ if (this.embedded && this.scrollElement) {
24203
+ this.scrollElement.scrollTo({ top: 0, behavior: 'smooth' });
24204
+ }
24205
+ else {
24206
+ window.scrollTo({ top: 0, behavior: 'smooth' });
24207
+ }
24179
24208
  if (!this.isPinned()) {
24180
24209
  this.isHovered.set(false);
24181
24210
  }