Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions plugins/beta/draw-ol/src/draw/drawInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const wireInputEvents = ({
updateRubberbanding, placeVertex
}) => {
const onCenterChange = () => {
if (getInterfaceType() !== 'pointer') {
if (getInterfaceType() !== 'mouse') {
updateRubberbanding()
}
}
Expand Down Expand Up @@ -91,7 +91,7 @@ const wireInputEvents = ({

const onPointerdown = (e) => {
if (e.pointerType !== 'touch') {
setInterfaceType('pointer')
setInterfaceType('mouse')
clearLastCoord()
}
}
Expand All @@ -101,7 +101,7 @@ const wireInputEvents = ({
}

const onPointerMove = () => {
if (getInterfaceType() === 'pointer') {
if (getInterfaceType() === 'mouse') {
return
}
updateRubberbanding()
Expand All @@ -127,7 +127,7 @@ const wireInputEvents = ({

export const createDrawInput = ({ drawInteraction, options }) => {
const { container, addVertexButtonId, mapProvider, snap, onUndo, canFinish } = options
let interfaceType = options.interfaceType
let interfaceType = options.interfaceType ?? 'mouse'
let sketchFeature = null
let lastPlacedCoord = null

Expand All @@ -146,6 +146,12 @@ export const createDrawInput = ({ drawInteraction, options }) => {

const updateRubberbanding = () => {
if (!sketchFeature) {
// No sketch yet — update snap indicator at crosshair position so targets are
// visible before the first vertex is placed (touch/keyboard only; mouse uses
// the OL snap interaction's pointermove handler instead).
if (interfaceType !== 'mouse' && snap) {
snap.apply(mapProvider.getCenter())
}
return
}
const geom = sketchFeature.getGeometry()
Expand All @@ -154,7 +160,7 @@ export const createDrawInput = ({ drawInteraction, options }) => {
return
}
const raw = mapProvider.getCenter()
const centerCoord = (interfaceType !== 'pointer' && snap) ? snap.apply(raw) : raw
const centerCoord = (interfaceType !== 'mouse' && snap) ? snap.apply(raw) : raw
applyRubberbanding(geom, centerCoord)
}

Expand Down Expand Up @@ -192,7 +198,7 @@ export const createDrawInput = ({ drawInteraction, options }) => {

const placeVertex = () => {
const raw = mapProvider.getCenter()
const coord = (interfaceType !== 'pointer' && snap) ? snap.apply(raw) : raw
const coord = (interfaceType !== 'mouse' && snap) ? snap.apply(raw) : raw
snap?.hideIndicator()
if (sketchFeature) {
const geom = sketchFeature.getGeometry()
Expand Down Expand Up @@ -221,7 +227,7 @@ export const createDrawInput = ({ drawInteraction, options }) => {

// change:center fires once when a keyboard pan animation starts; postrender tracks each frame.
const onMapRender = () => {
if (interfaceType !== 'pointer' && olView?.getAnimating()) {
if (interfaceType !== 'mouse' && olView?.getAnimating()) {
updateRubberbanding()
}
}
Expand Down
8 changes: 4 additions & 4 deletions plugins/beta/draw-ol/src/edit/EditMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const createEditMode = ({ map, manager, options }) => {
selectedVertexType: null,
vertices: [],
midpoints: [],
interfaceType: interfaceType ?? 'pointer'
interfaceType: interfaceType ?? 'mouse'
}

const getState = () => state
Expand Down Expand Up @@ -210,7 +210,7 @@ export const createEditMode = ({ map, manager, options }) => {
touchHandler.updateTargetPosition()
return
}
state.interfaceType = 'pointer'
state.interfaceType = 'mouse'

const olPixel = map.getEventPixel(e)
const pixel = { x: olPixel[0], y: olPixel[1] }
Expand Down Expand Up @@ -242,10 +242,10 @@ export const createEditMode = ({ map, manager, options }) => {
if (e.pointerType !== 'mouse') {
return
}
if (state.interfaceType === 'pointer') {
if (state.interfaceType === 'mouse') {
return
}
state.interfaceType = 'pointer'
state.interfaceType = 'mouse'
touchHandler.hide()
}

Expand Down
Loading