@bbki.ng/bb-msg-history 0.11.0 → 0.11.1

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/component.js CHANGED
@@ -271,7 +271,7 @@ export class BBMsgHistory extends HTMLElement {
271
271
  const isInfinite = this.hasAttribute('infinite');
272
272
  if (container && !isInfinite) {
273
273
  container.scrollTop = container.scrollHeight;
274
- this._setupScrollTracking(container, scrollButton);
274
+ this._setupScrollTracking(container, scrollButton, { skipInitialCheck: true });
275
275
  }
276
276
  if (scrollButton && !isInfinite) {
277
277
  scrollButton.addEventListener('click', () => {
@@ -304,7 +304,7 @@ export class BBMsgHistory extends HTMLElement {
304
304
  `;
305
305
  }
306
306
  }
307
- _setupScrollTracking(container, button) {
307
+ _setupScrollTracking(container, button, options) {
308
308
  const checkScrollPosition = () => {
309
309
  const threshold = 50; // pixels from bottom
310
310
  const isAtBottom = container.scrollHeight - container.scrollTop - container.clientHeight < threshold;
@@ -315,8 +315,10 @@ export class BBMsgHistory extends HTMLElement {
315
315
  button.classList.toggle('visible', shouldShow);
316
316
  }
317
317
  };
318
- // Check initial state
319
- checkScrollPosition();
318
+ // Check initial state unless skipped
319
+ if (!options?.skipInitialCheck) {
320
+ checkScrollPosition();
321
+ }
320
322
  // Listen for scroll events with passive listener for performance
321
323
  container.addEventListener('scroll', checkScrollPosition, { passive: true });
322
324
  // Also check on resize
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/bb-msg-history",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "A chat-style message history web component",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
package/src/component.ts CHANGED
@@ -339,7 +339,7 @@ export class BBMsgHistory extends HTMLElement {
339
339
 
340
340
  if (container && !isInfinite) {
341
341
  container.scrollTop = container.scrollHeight;
342
- this._setupScrollTracking(container, scrollButton);
342
+ this._setupScrollTracking(container, scrollButton, { skipInitialCheck: true });
343
343
  }
344
344
 
345
345
  if (scrollButton && !isInfinite) {
@@ -376,7 +376,11 @@ export class BBMsgHistory extends HTMLElement {
376
376
  }
377
377
  }
378
378
 
379
- private _setupScrollTracking(container: HTMLElement, button: HTMLButtonElement): void {
379
+ private _setupScrollTracking(
380
+ container: HTMLElement,
381
+ button: HTMLButtonElement,
382
+ options?: { skipInitialCheck?: boolean }
383
+ ): void {
380
384
  const checkScrollPosition = () => {
381
385
  const threshold = 50; // pixels from bottom
382
386
  const isAtBottom =
@@ -390,8 +394,10 @@ export class BBMsgHistory extends HTMLElement {
390
394
  }
391
395
  };
392
396
 
393
- // Check initial state
394
- checkScrollPosition();
397
+ // Check initial state unless skipped
398
+ if (!options?.skipInitialCheck) {
399
+ checkScrollPosition();
400
+ }
395
401
 
396
402
  // Listen for scroll events with passive listener for performance
397
403
  container.addEventListener('scroll', checkScrollPosition, { passive: true });