@bbki.ng/bb-msg-history 0.12.0 → 0.13.0
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.d.ts +7 -0
- package/dist/component.js +20 -0
- package/package.json +1 -1
- package/src/component.ts +24 -0
package/dist/component.d.ts
CHANGED
|
@@ -41,6 +41,13 @@ export declare class BBMsgHistory extends HTMLElement {
|
|
|
41
41
|
* el.appendMessage({ author: 'bob', text: 'How are you?' });
|
|
42
42
|
*/
|
|
43
43
|
appendMessage(message: Message): this;
|
|
44
|
+
/**
|
|
45
|
+
* Scroll to the bottom of the message history.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* el.scrollToBottom(); // Scroll with smooth animation
|
|
49
|
+
*/
|
|
50
|
+
scrollToBottom(): this;
|
|
44
51
|
private _appendSingleMessage;
|
|
45
52
|
connectedCallback(): void;
|
|
46
53
|
disconnectedCallback(): void;
|
package/dist/component.js
CHANGED
|
@@ -76,6 +76,26 @@ export class BBMsgHistory extends HTMLElement {
|
|
|
76
76
|
this._setupMutationObserver();
|
|
77
77
|
return this;
|
|
78
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Scroll to the bottom of the message history.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* el.scrollToBottom(); // Scroll with smooth animation
|
|
84
|
+
*/
|
|
85
|
+
scrollToBottom() {
|
|
86
|
+
if (this.hasAttribute('infinite')) {
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
const container = this.shadowRoot?.querySelector('.history');
|
|
90
|
+
if (!container) {
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
container.scrollTo({
|
|
94
|
+
top: container.scrollHeight,
|
|
95
|
+
behavior: 'smooth',
|
|
96
|
+
});
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
79
99
|
_appendSingleMessage(message) {
|
|
80
100
|
const container = this.shadowRoot.querySelector('.history');
|
|
81
101
|
// If empty state or no container, do full render first
|
package/package.json
CHANGED
package/src/component.ts
CHANGED
|
@@ -92,6 +92,30 @@ export class BBMsgHistory extends HTMLElement {
|
|
|
92
92
|
return this;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Scroll to the bottom of the message history.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* el.scrollToBottom(); // Scroll with smooth animation
|
|
100
|
+
*/
|
|
101
|
+
scrollToBottom(): this {
|
|
102
|
+
if (this.hasAttribute('infinite')) {
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const container = this.shadowRoot?.querySelector('.history') as HTMLElement | null;
|
|
107
|
+
if (!container) {
|
|
108
|
+
return this;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
container.scrollTo({
|
|
112
|
+
top: container.scrollHeight,
|
|
113
|
+
behavior: 'smooth',
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
|
|
95
119
|
private _appendSingleMessage(message: Message): void {
|
|
96
120
|
const container = this.shadowRoot!.querySelector('.history') as HTMLElement;
|
|
97
121
|
|