");
+ p.set_text_content(Some(&output_str));
+
+ // check if scrolled to top
+
// DEBUG
- //log::info!("{}", &output_str);
- if let Some(info_text) =
- shared.info_text_ref.cast:: ");
- p.set_text_content(Some(&output_str));
+ //log::info!(
+ // "pre: scroll top is {}, scroll height is {}",
+ // info_text.scroll_top(),
+ // info_text.scroll_height()
+ //);
+ let at_top: bool = info_text.scroll_top()
+ <= INFO_TEXT_HEIGHT - info_text.scroll_height();
- // check if scrolled to bottom
- let at_bottom: bool = info_text.scroll_top() + INFO_TEXT_HEIGHT
- >= info_text.scroll_height();
-
- // append text to output
+ // append text to output
+ info_text
+ .append_with_node_1(&p)
+ .expect("should be able to append to info_text");
+ while info_text.child_element_count() > INFO_TEXT_MAX_ITEMS {
info_text
- .append_with_node_1(&p)
- .expect("should be able to append to info_text");
- while info_text.child_element_count() > INFO_TEXT_MAX_ITEMS {
- info_text
- .remove_child(&info_text.first_child().unwrap())
- .expect("should be able to limit items in info_text");
- }
-
- // scroll to bottom only if at bottom
- if at_bottom {
- info_text.set_scroll_top(info_text.scroll_height());
- }
- } else {
- log::warn!("Failed to get \"info_text\"");
+ .remove_child(&info_text.first_child().unwrap())
+ .expect("should be able to limit items in info_text");
}
+
+ // scroll to bottom only if at bottom
+
+ // DEBUG
+ //log::info!("at_top is {}", if at_top { "true" } else { "false" });
+
+ if at_top {
+ info_text
+ .set_scroll_top(INFO_TEXT_HEIGHT - info_text.scroll_height());
+ }
+
+ // DEBUG
+ //log::info!(
+ // "post: scroll top is {}, scroll height is {}",
+ // info_text.scroll_top(),
+ // info_text.scroll_height()
+ //);
+ } else {
+ log::warn!("Failed to get \"info_text\"");
}
}
}
- } else {
- break;
}
}
}