mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: selection menu show in wrong position
This commit is contained in:
parent
381913307c
commit
e7adc3bcbf
@ -61,19 +61,27 @@ class SelectionMenu implements SelectionMenuService {
|
|||||||
// Just subtract the padding here as a result.
|
// Just subtract the padding here as a result.
|
||||||
const menuHeight = 200.0;
|
const menuHeight = 200.0;
|
||||||
const menuOffset = Offset(10, 10);
|
const menuOffset = Offset(10, 10);
|
||||||
final baseOffset =
|
final editorOffset =
|
||||||
editorState.renderBox?.localToGlobal(Offset.zero) ?? Offset.zero;
|
editorState.renderBox?.localToGlobal(Offset.zero) ?? Offset.zero;
|
||||||
var offset = selectionRects.first.bottomRight + menuOffset;
|
final editorHeight = editorState.renderBox!.size.height;
|
||||||
if (offset.dy >=
|
|
||||||
baseOffset.dy + editorState.renderBox!.size.height - menuHeight) {
|
// show below defualt
|
||||||
offset = selectionRects.first.topRight - menuOffset;
|
var showBelow = true;
|
||||||
offset = offset.translate(0, -menuHeight);
|
final bottomRight = selectionRects.first.bottomRight;
|
||||||
|
final topRight = selectionRects.first.topRight;
|
||||||
|
var offset = bottomRight + menuOffset;
|
||||||
|
// overflow
|
||||||
|
if (offset.dy + menuHeight >= editorOffset.dy + editorHeight) {
|
||||||
|
// show above
|
||||||
|
offset = topRight - menuOffset;
|
||||||
|
showBelow = false;
|
||||||
}
|
}
|
||||||
_topLeft = offset;
|
_topLeft = offset;
|
||||||
|
|
||||||
_selectionMenuEntry = OverlayEntry(builder: (context) {
|
_selectionMenuEntry = OverlayEntry(builder: (context) {
|
||||||
return Positioned(
|
return Positioned(
|
||||||
top: offset.dy,
|
top: showBelow ? offset.dy : null,
|
||||||
|
bottom: showBelow ? null : editorHeight - offset.dy,
|
||||||
left: offset.dx,
|
left: offset.dx,
|
||||||
child: SelectionMenuWidget(
|
child: SelectionMenuWidget(
|
||||||
items: [
|
items: [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user