Skip to content

Commit f99b0b8

Browse files
Tweaking the code
1 parent b999d9f commit f99b0b8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

egui_web/src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1221,13 +1221,14 @@ fn is_mobile() -> Option<bool> {
12211221
// On mobile devices, there is no need to do that.
12221222
fn move_text_cursor(cursor: &Option<egui::Pos2>, canvas_id: &str) -> Option<()> {
12231223
let style = text_agent().style();
1224-
let rect = text_agent().get_bounding_client_rect();
12251224
// Note: movint agent on mobile devices will lead to unpredictable scroll.
12261225
if is_mobile() == Some(false) {
12271226
cursor.as_ref().and_then(|&egui::Pos2 { x, y }| {
12281227
let canvas = canvas_element(canvas_id)?;
1229-
let y = (y + (canvas.scroll_top() + canvas.offset_top()) as f32)
1230-
.min(canvas.client_height() as f32 - rect.height() as f32);
1228+
let y = (y + (canvas.scroll_top() + canvas.offset_top()) as f32).min(
1229+
canvas.client_height() as f32
1230+
- text_agent().get_bounding_client_rect().height() as f32,
1231+
);
12311232
let x = x + (canvas.scroll_left() + canvas.offset_left()) as f32;
12321233
// Canvas is translated 50% horizontally in html.
12331234
let x = x - canvas.offset_width() as f32 / 2.0;

0 commit comments

Comments
 (0)