1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Cover iframe while MenuItems is dragging

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-11-26 10:40:25 +03:00
parent ae97e16e9d
commit 4f7aaf5f53
2 changed files with 24 additions and 2 deletions

View File

@ -29,6 +29,14 @@
width: var(--hotbar-width);
overflow: hidden;
&.draggingOver::after {
content: " ";
position: fixed;
left: var(--hotbar-width);
width: 100%;
height: 100%;
}
.HotbarItems {
--cellWidth: 40px;
--cellHeight: 40px;

View File

@ -33,6 +33,7 @@ import { HotbarSelector } from "./hotbar-selector";
import { HotbarCell } from "./hotbar-cell";
import { HotbarIcon } from "./hotbar-icon";
import { defaultHotbarCells, HotbarItem } from "../../../common/hotbar-types";
import { makeObservable, observable } from "mobx";
interface Props {
className?: IClassName;
@ -40,6 +41,13 @@ interface Props {
@observer
export class HotbarMenu extends React.Component<Props> {
@observable draggingOver = false;
constructor(props: Props) {
super(props);
makeObservable(this);
}
get hotbar() {
return HotbarStore.getInstance().getActive();
}
@ -54,9 +62,15 @@ export class HotbarMenu extends React.Component<Props> {
return catalogEntityRegistry.getById(item?.entity.uid) ?? null;
}
onDragStart() {
this.draggingOver = true;
}
onDragEnd(result: DropResult) {
const { source, destination } = result;
this.draggingOver = false;
if (!destination) { // Dropped outside of the list
return;
}
@ -165,9 +179,9 @@ export class HotbarMenu extends React.Component<Props> {
const hotbar = hotbarStore.getActive();
return (
<div className={cssNames("HotbarMenu flex column", className)}>
<div className={cssNames("HotbarMenu flex column", { draggingOver: this.draggingOver }, className)}>
<div className="HotbarItems flex column gaps">
<DragDropContext onDragEnd={this.onDragEnd.bind(this)}>
<DragDropContext onDragStart={this.onDragStart.bind(this)} onDragEnd={this.onDragEnd.bind(this)}>
{this.renderGrid()}
</DragDropContext>
</div>