powergrid-viewer 2.1.1 → 2.1.2
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/package.json
CHANGED
|
@@ -32,6 +32,7 @@ export default class InlineLog extends Vue {
|
|
|
32
32
|
@Prop({ default: () => [] }) entries!: string[];
|
|
33
33
|
@Prop({ default: '' }) mapName!: string;
|
|
34
34
|
follow = true;
|
|
35
|
+
private feedObserver?: ResizeObserver;
|
|
35
36
|
get illustratedEntries() {
|
|
36
37
|
return this.entries.map((entry) => {
|
|
37
38
|
const parts: { html?: string; plant?: PowerPlant }[] = [];
|
|
@@ -54,8 +55,15 @@ export default class InlineLog extends Vue {
|
|
|
54
55
|
} cities`;
|
|
55
56
|
}
|
|
56
57
|
mounted() {
|
|
58
|
+
this.feedObserver = new ResizeObserver(() => {
|
|
59
|
+
if (this.follow) this.scrollToLatest();
|
|
60
|
+
});
|
|
61
|
+
this.feedObserver.observe(this.$refs.feed as HTMLElement);
|
|
57
62
|
this.scrollToLatest();
|
|
58
63
|
}
|
|
64
|
+
beforeDestroy() {
|
|
65
|
+
this.feedObserver?.disconnect();
|
|
66
|
+
}
|
|
59
67
|
@Watch('entries') changed() {
|
|
60
68
|
if (this.follow) {
|
|
61
69
|
this.$nextTick(this.scrollToLatest);
|
|
@@ -63,13 +71,13 @@ export default class InlineLog extends Vue {
|
|
|
63
71
|
}
|
|
64
72
|
scrollToLatest() {
|
|
65
73
|
const feed = this.$refs.feed as HTMLElement;
|
|
66
|
-
if (feed) {
|
|
74
|
+
if (feed?.clientHeight) {
|
|
67
75
|
feed.scrollTop = feed.scrollHeight;
|
|
68
76
|
}
|
|
69
77
|
}
|
|
70
78
|
onScroll() {
|
|
71
79
|
const feed = this.$refs.feed as HTMLElement;
|
|
72
|
-
this.follow = feed.scrollHeight - feed.scrollTop - feed.clientHeight < 32;
|
|
80
|
+
if (feed.clientHeight) this.follow = feed.scrollHeight - feed.scrollTop - feed.clientHeight < 32;
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
83
|
</script>
|
package/src/game-chat.ts
CHANGED
|
@@ -301,7 +301,7 @@ export function mountGameChat(emitter: ChatEmitter, host: Element): void {
|
|
|
301
301
|
}
|
|
302
302
|
};
|
|
303
303
|
list.onscroll = () => {
|
|
304
|
-
following = list.scrollHeight - list.scrollTop - list.clientHeight < 32;
|
|
304
|
+
if (list.clientHeight) following = list.scrollHeight - list.scrollTop - list.clientHeight < 32;
|
|
305
305
|
read();
|
|
306
306
|
};
|
|
307
307
|
panel.ontoggle = () => {
|
|
@@ -314,10 +314,12 @@ export function mountGameChat(emitter: ChatEmitter, host: Element): void {
|
|
|
314
314
|
window.addEventListener('focus', read);
|
|
315
315
|
window.addEventListener('resize', read);
|
|
316
316
|
const sizing = new ResizeObserver(() => {
|
|
317
|
+
if (following && list.clientHeight) list.scrollTop = list.scrollHeight;
|
|
317
318
|
updateShortcut();
|
|
318
319
|
read();
|
|
319
320
|
});
|
|
320
321
|
sizing.observe(panel);
|
|
322
|
+
sizing.observe(list);
|
|
321
323
|
document.addEventListener('visibilitychange', read);
|
|
322
324
|
status.textContent = reason;
|
|
323
325
|
controls();
|