@bbki.ng/bb-msg-history 0.13.0 → 0.13.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 +13 -11
- package/package.json +1 -1
- package/src/component.ts +15 -13
package/dist/component.js
CHANGED
|
@@ -149,11 +149,13 @@ export class BBMsgHistory extends HTMLElement {
|
|
|
149
149
|
this._isProgrammaticScroll = false;
|
|
150
150
|
}, 300);
|
|
151
151
|
// Hide scroll button since we're scrolling to bottom
|
|
152
|
-
|
|
153
|
-
if (scrollButton && this._scrollButtonVisible) {
|
|
152
|
+
if (this._scrollButtonVisible) {
|
|
154
153
|
this._scrollButtonVisible = false;
|
|
155
|
-
scrollButton.
|
|
156
|
-
|
|
154
|
+
const scrollButton = this.shadowRoot.querySelector('.scroll-to-bottom');
|
|
155
|
+
if (scrollButton) {
|
|
156
|
+
scrollButton.classList.remove('visible');
|
|
157
|
+
}
|
|
158
|
+
// Dispatch hide event (always, regardless of button visibility)
|
|
157
159
|
this.dispatchEvent(new CustomEvent('bb-scrollbuttonhide', {
|
|
158
160
|
bubbles: true,
|
|
159
161
|
composed: true,
|
|
@@ -303,12 +305,9 @@ export class BBMsgHistory extends HTMLElement {
|
|
|
303
305
|
_setupAfterRender() {
|
|
304
306
|
requestAnimationFrame(() => {
|
|
305
307
|
const container = this.shadowRoot.querySelector('.history');
|
|
306
|
-
const
|
|
307
|
-
const scrollButton = hideScrollButton
|
|
308
|
-
? null
|
|
309
|
-
: this.shadowRoot.querySelector('.scroll-to-bottom');
|
|
308
|
+
const scrollButton = this.shadowRoot.querySelector('.scroll-to-bottom');
|
|
310
309
|
const isInfinite = this.hasAttribute('infinite');
|
|
311
|
-
if (container && !isInfinite
|
|
310
|
+
if (container && !isInfinite) {
|
|
312
311
|
// Mark as programmatic scroll to prevent triggering user scroll detection
|
|
313
312
|
this._isProgrammaticScroll = true;
|
|
314
313
|
container.scrollTop = container.scrollHeight;
|
|
@@ -367,8 +366,11 @@ export class BBMsgHistory extends HTMLElement {
|
|
|
367
366
|
const shouldShow = !isAtBottom && hasOverflow && this._userHasScrolledManually && isScrollingUp;
|
|
368
367
|
if (shouldShow !== this._scrollButtonVisible) {
|
|
369
368
|
this._scrollButtonVisible = shouldShow;
|
|
370
|
-
|
|
371
|
-
|
|
369
|
+
// Only toggle button visibility if button exists
|
|
370
|
+
if (button) {
|
|
371
|
+
button.classList.toggle('visible', shouldShow);
|
|
372
|
+
}
|
|
373
|
+
// Dispatch custom event (always, regardless of button visibility)
|
|
372
374
|
this.dispatchEvent(new CustomEvent(shouldShow ? 'bb-scrollbuttonshow' : 'bb-scrollbuttonhide', {
|
|
373
375
|
bubbles: true,
|
|
374
376
|
composed: true,
|
package/package.json
CHANGED
package/src/component.ts
CHANGED
|
@@ -190,12 +190,14 @@ export class BBMsgHistory extends HTMLElement {
|
|
|
190
190
|
}, 300);
|
|
191
191
|
|
|
192
192
|
// Hide scroll button since we're scrolling to bottom
|
|
193
|
-
|
|
194
|
-
if (scrollButton && this._scrollButtonVisible) {
|
|
193
|
+
if (this._scrollButtonVisible) {
|
|
195
194
|
this._scrollButtonVisible = false;
|
|
196
|
-
scrollButton.
|
|
195
|
+
const scrollButton = this.shadowRoot!.querySelector('.scroll-to-bottom') as HTMLButtonElement | null;
|
|
196
|
+
if (scrollButton) {
|
|
197
|
+
scrollButton.classList.remove('visible');
|
|
198
|
+
}
|
|
197
199
|
|
|
198
|
-
// Dispatch hide event
|
|
200
|
+
// Dispatch hide event (always, regardless of button visibility)
|
|
199
201
|
this.dispatchEvent(
|
|
200
202
|
new CustomEvent('bb-scrollbuttonhide', {
|
|
201
203
|
bubbles: true,
|
|
@@ -380,20 +382,17 @@ export class BBMsgHistory extends HTMLElement {
|
|
|
380
382
|
private _setupAfterRender(): void {
|
|
381
383
|
requestAnimationFrame(() => {
|
|
382
384
|
const container = this.shadowRoot!.querySelector('.history') as HTMLElement;
|
|
383
|
-
const
|
|
384
|
-
const scrollButton = hideScrollButton
|
|
385
|
-
? null
|
|
386
|
-
: (this.shadowRoot!.querySelector('.scroll-to-bottom') as HTMLButtonElement);
|
|
385
|
+
const scrollButton = this.shadowRoot!.querySelector('.scroll-to-bottom') as HTMLButtonElement | null;
|
|
387
386
|
const isInfinite = this.hasAttribute('infinite');
|
|
388
387
|
|
|
389
|
-
if (container && !isInfinite
|
|
388
|
+
if (container && !isInfinite) {
|
|
390
389
|
// Mark as programmatic scroll to prevent triggering user scroll detection
|
|
391
390
|
this._isProgrammaticScroll = true;
|
|
392
391
|
container.scrollTop = container.scrollHeight;
|
|
393
392
|
requestAnimationFrame(() => {
|
|
394
393
|
this._isProgrammaticScroll = false;
|
|
395
394
|
});
|
|
396
|
-
this._setupScrollTracking(container, scrollButton
|
|
395
|
+
this._setupScrollTracking(container, scrollButton, { skipInitialCheck: true });
|
|
397
396
|
}
|
|
398
397
|
|
|
399
398
|
if (scrollButton && !isInfinite) {
|
|
@@ -432,7 +431,7 @@ export class BBMsgHistory extends HTMLElement {
|
|
|
432
431
|
|
|
433
432
|
private _setupScrollTracking(
|
|
434
433
|
container: HTMLElement,
|
|
435
|
-
button: HTMLButtonElement,
|
|
434
|
+
button: HTMLButtonElement | null,
|
|
436
435
|
options?: { skipInitialCheck?: boolean }
|
|
437
436
|
): void {
|
|
438
437
|
const checkScrollPosition = () => {
|
|
@@ -457,9 +456,12 @@ export class BBMsgHistory extends HTMLElement {
|
|
|
457
456
|
|
|
458
457
|
if (shouldShow !== this._scrollButtonVisible) {
|
|
459
458
|
this._scrollButtonVisible = shouldShow;
|
|
460
|
-
|
|
459
|
+
// Only toggle button visibility if button exists
|
|
460
|
+
if (button) {
|
|
461
|
+
button.classList.toggle('visible', shouldShow);
|
|
462
|
+
}
|
|
461
463
|
|
|
462
|
-
// Dispatch custom event
|
|
464
|
+
// Dispatch custom event (always, regardless of button visibility)
|
|
463
465
|
this.dispatchEvent(
|
|
464
466
|
new CustomEvent(shouldShow ? 'bb-scrollbuttonshow' : 'bb-scrollbuttonhide', {
|
|
465
467
|
bubbles: true,
|