Skip to content

Commit b6c2700

Browse files
authored
Allow to move link source or target with LinkActionMoveEndpoint on touchscreen (#135)
1 parent 87736dd commit b6c2700

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1010
* Allow to manipulate link vertices on touchscreen (only in Firefox for now due to [bug](https://gsap.com/community/forums/topic/15870-svg-draggable-chrome-android-problems/));
1111
* Allow to select multiple elements with `Selection` with touch when `CanvasApi.pointerMode` is `selection`;
1212
* Allow to establish new links with `SelectionActionEstablishLink` on touchscreen;
13+
* Allow to move link source or target with `LinkActionMoveEndpoint` on touchscreen;
1314
* Enable `showPointerModeToggle` on `ZoomControl` by default (can be disabled by passing `false`).
1415
- Allow to customize how resource anchors and asset URLs (e.g. images or downloadable files) are resolved via `DataLocaleProvider.{prepareAnchor, resolveAssetUrl}`:
1516
* Resolve anchors and image thumbnail URLs in `StandardEntity`, `ClassicEntity` and `SelectionActionAnchor`;

src/widgets/linkAction.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ export interface LinkActionProps extends LinkActionStyleProps {
119119
* Raw handler for mouse down event on the action button.
120120
*/
121121
onMouseDown?: (e: React.MouseEvent) => void;
122+
/**
123+
* Raw handler for pointer down event on the action button.
124+
*/
125+
onPointerDown?: (e: React.PointerEvent) => void;
122126
/**
123127
* Action content.
124128
*/
@@ -135,7 +139,7 @@ const CLASS_NAME = 'reactodia-link-action';
135139
export function LinkAction(props: LinkActionProps) {
136140
const {
137141
dockSide, dockIndex, disabled, className, title, hotkey,
138-
onSelect, onMouseDown, children,
142+
onSelect, onMouseDown, onPointerDown, children,
139143
} = props;
140144

141145
const {getPosition} = useLinkActionContext();
@@ -149,7 +153,8 @@ export function LinkAction(props: LinkActionProps) {
149153
disabled={disabled}
150154
title={titleWithHotkey}
151155
onClick={onSelect}
152-
onMouseDown={onMouseDown}>
156+
onMouseDown={onMouseDown}
157+
onPointerDown={onPointerDown}>
153158
{children}
154159
</button>
155160
);
@@ -448,7 +453,8 @@ function LinkActionMoveRelationEndpoint(
448453
: t.text('link_action.move_relation.move_target_title')
449454
)}
450455
disabled={linkIsDeleted}
451-
onMouseDown={e => {
456+
onPointerDown={e => {
457+
e.preventDefault();
452458
const point = canvas.metrics.pageToPaperCoords(e.pageX, e.pageY);
453459
getCommandBus(VisualAuthoringTopic)
454460
.trigger('startDragEdit', {
@@ -494,7 +500,8 @@ function LinkActionMoveAnnotationEndpoint(
494500
? t.text('link_action.move_relation.move_source_title')
495501
: t.text('link_action.move_relation.move_target_title')
496502
)}
497-
onMouseDown={e => {
503+
onPointerDown={e => {
504+
e.preventDefault();
498505
const point = canvas.metrics.pageToPaperCoords(e.pageX, e.pageY);
499506
getCommandBus(AnnotationTopic)
500507
.trigger('startDragOperation', {

styles/widgets/_linkAction.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
}
3737

3838
&__endpoint {
39+
touch-action: none;
3940
color: theme.$color-primary;
4041
background: transparent;
4142
}

0 commit comments

Comments
 (0)