Moved notes to be above drawings

This commit is contained in:
Mitchell McCaffrey 2021-01-28 16:26:28 +11:00
parent 2108d32501
commit ff8d7c1547
4 changed files with 21 additions and 4 deletions

View File

@ -411,6 +411,7 @@ function Map({
onNoteDragEnd={() => onNoteDragEnd={() =>
setNoteDraggingOptions({ ...noteDraggingOptions, dragging: false }) setNoteDraggingOptions({ ...noteDraggingOptions, dragging: false })
} }
fadeOnHover={selectedToolId === "drawing"}
/> />
); );
@ -455,8 +456,8 @@ function Map({
disabledControls={disabledControls} disabledControls={disabledControls}
> >
{mapGrid} {mapGrid}
{mapNotes}
{mapDrawing} {mapDrawing}
{mapNotes}
{mapTokens} {mapTokens}
{mapFog} {mapFog}
{mapPointer} {mapPointer}

View File

@ -10,7 +10,6 @@ import {
getUpdatedShapeData, getUpdatedShapeData,
getStrokeWidth, getStrokeWidth,
} from "../../helpers/drawing"; } from "../../helpers/drawing";
import { getRelativePointerPositionNormalized } from "../../helpers/konva";
import * as Vector2 from "../../helpers/vector2"; import * as Vector2 from "../../helpers/vector2";
function MapMeasure({ map, selectedToolSettings, active, gridSize }) { function MapMeasure({ map, selectedToolSettings, active, gridSize }) {

View File

@ -7,7 +7,6 @@ import MapStageContext from "../../contexts/MapStageContext";
import AuthContext from "../../contexts/AuthContext"; import AuthContext from "../../contexts/AuthContext";
import { getBrushPosition } from "../../helpers/drawing"; import { getBrushPosition } from "../../helpers/drawing";
import { getRelativePointerPositionNormalized } from "../../helpers/konva";
import Note from "../note/Note"; import Note from "../note/Note";
@ -24,6 +23,7 @@ function MapNotes({
draggable, draggable,
onNoteDragStart, onNoteDragStart,
onNoteDragEnd, onNoteDragEnd,
fadeOnHover,
}) { }) {
const { interactionEmitter } = useContext(MapInteractionContext); const { interactionEmitter } = useContext(MapInteractionContext);
const { userId } = useContext(AuthContext); const { userId } = useContext(AuthContext);
@ -111,6 +111,7 @@ function MapNotes({
onNoteChange={onNoteChange} onNoteChange={onNoteChange}
onNoteDragStart={onNoteDragStart} onNoteDragStart={onNoteDragStart}
onNoteDragEnd={onNoteDragEnd} onNoteDragEnd={onNoteDragEnd}
fadeOnHover={fadeOnHover}
/> />
))} ))}
<Group ref={creatingNoteRef}> <Group ref={creatingNoteRef}>

View File

@ -19,6 +19,7 @@ function Note({
draggable, draggable,
onNoteDragStart, onNoteDragStart,
onNoteDragEnd, onNoteDragEnd,
fadeOnHover,
}) { }) {
const { userId } = useContext(AuthContext); const { userId } = useContext(AuthContext);
const { mapWidth, mapHeight, setPreventMapInteraction } = useContext( const { mapWidth, mapHeight, setPreventMapInteraction } = useContext(
@ -89,6 +90,19 @@ function Note({
} }
} }
const [noteOpacity, setNoteOpacity] = useState(1);
function handlePointerEnter() {
if (fadeOnHover) {
setNoteOpacity(0.5);
}
}
function handlePointerLeave() {
if (noteOpacity !== 1.0) {
setNoteOpacity(1.0);
}
}
const [fontSize, setFontSize] = useState(1); const [fontSize, setFontSize] = useState(1);
useEffect(() => { useEffect(() => {
const text = textRef.current; const text = textRef.current;
@ -160,7 +174,9 @@ function Note({
onMouseUp={handlePointerUp} onMouseUp={handlePointerUp}
onTouchStart={handlePointerDown} onTouchStart={handlePointerDown}
onTouchEnd={handlePointerUp} onTouchEnd={handlePointerUp}
opacity={note.visible ? 1.0 : 0.5} onMouseEnter={handlePointerEnter}
onMouseLeave={handlePointerLeave}
opacity={note.visible ? noteOpacity : 0.5}
> >
{!note.textOnly && ( {!note.textOnly && (
<Rect <Rect