Skip to content

Commit

Permalink
[logbook] fix scrolling on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
KapJI committed Feb 21, 2020
1 parent 4675579 commit dc2da20
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/panels/logbook/ha-logbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from "lit-element";
import { HomeAssistant } from "../../types";
import { fireEvent } from "../../common/dom/fire_event";
import "lit-virtualizer";
import { scroll } from "lit-virtualizer";
import { LogbookEntry } from "../../data/logbook";

class HaLogbook extends LitElement {
Expand Down Expand Up @@ -44,19 +44,23 @@ class HaLogbook extends LitElement {
}

return html`
<lit-virtualizer
.items=${this.entries}
.renderItem=${(item: LogbookEntry, index: number) =>
this._renderLogbookItem(item, index)}
style="height: 100%;"
></lit-virtualizer>
<div>
${scroll({
items: this.entries,
renderItem: (item: LogbookEntry, index?: number) =>
this._renderLogbookItem(item, index),
})}
</div>
`;
}

private _renderLogbookItem(
item: LogbookEntry,
index: number
index?: number
): TemplateResult {
if (!index) {
return html``;
}
const previous = this.entries[index - 1];
const state = item.entity_id ? this.hass.states[item.entity_id] : undefined;
return html`
Expand Down Expand Up @@ -149,6 +153,18 @@ class HaLogbook extends LitElement {
a {
color: var(--primary-color);
}
.uni-virtualizer-host {
display: block;
position: relative;
contain: strict;
height: 100%;
overflow: auto;
}
.uni-virtualizer-host > * {
box-sizing: border-box;
}
`;
}
}
Expand Down

0 comments on commit dc2da20

Please sign in to comment.