From 028b370ead58e96d8478ab7261917ed6661e8c67 Mon Sep 17 00:00:00 2001 From: Ruslan Sayfutdinov Date: Mon, 24 Feb 2020 12:50:22 +0000 Subject: [PATCH] [logbook] fix scrolling on iOS (#4950) * [logbook] fix scrolling on iOS * Update styling * Update ha-logbook.ts Co-authored-by: Bram Kragten --- src/panels/logbook/ha-logbook.ts | 33 ++++++--- src/panels/logbook/ha-panel-logbook.js | 92 ++++++++++++-------------- 2 files changed, 67 insertions(+), 58 deletions(-) diff --git a/src/panels/logbook/ha-logbook.ts b/src/panels/logbook/ha-logbook.ts index f72edab10c..91a2890b54 100644 --- a/src/panels/logbook/ha-logbook.ts +++ b/src/panels/logbook/ha-logbook.ts @@ -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 { @@ -44,19 +44,23 @@ class HaLogbook extends LitElement { } return html` - - this._renderLogbookItem(item, index)} - style="height: 100%;" - > +
+ ${scroll({ + items: this.entries, + renderItem: (item: LogbookEntry, index?: number) => + this._renderLogbookItem(item, index), + })} +
`; } 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` @@ -149,6 +153,19 @@ class HaLogbook extends LitElement { a { color: var(--primary-color); } + + .uni-virtualizer-host { + display: block; + position: relative; + contain: strict; + height: 100%; + overflow: auto; + padding: 0 16px; + } + + .uni-virtualizer-host > * { + box-sizing: border-box; + } `; } } diff --git a/src/panels/logbook/ha-panel-logbook.js b/src/panels/logbook/ha-panel-logbook.js index 3c2c0d0f85..2deaf83a67 100644 --- a/src/panels/logbook/ha-panel-logbook.js +++ b/src/panels/logbook/ha-panel-logbook.js @@ -27,10 +27,6 @@ class HaPanelLogbook extends LocalizeMixin(PolymerElement) { static get template() { return html`