Draft Widget::overlay idempotency

This commit is contained in:
Héctor Ramón Jiménez 2020-07-05 05:44:10 +02:00
parent 61f22b1db2
commit 625979b665
11 changed files with 134 additions and 131 deletions

View file

@ -319,14 +319,16 @@ where
fn overlay(
&mut self,
layout: Layout<'_>,
) -> Option<Overlay<'a, Message, Renderer>> {
self.content
) -> Option<Overlay<'_, Message, Renderer>> {
let Self { content, state, .. } = self;
content
.overlay(layout.children().next().unwrap())
.map(|overlay| {
let bounds = layout.bounds();
let content_layout = layout.children().next().unwrap();
let content_bounds = content_layout.bounds();
let offset = self.state.offset(bounds, content_bounds);
let offset = state.offset(bounds, content_bounds);
overlay.translate(Vector::new(0.0, -(offset as f32)))
})