Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

Motion paths: fix double-click node removal + document curve/path gestures in ? help

nyblnet09e6ed60824c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index df892cf6..1d428a24 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -30,7 +30,17 @@ pre-1.0.
without changing its shape. Because the path is now stored as explicit cubics,
the old sample-and-re-smooth round-trip drift is gone: a motion path is
byte-stable across open/save, and existing decks reopen unchanged. Per-anchor
- speed (scroll a point) and the live preview dot are preserved.
+ speed (scroll a point) and the live preview dot are preserved. Double-clicking
+ a waypoint to remove it is detected directly on the point's mousedown (the
+ select-on-click redraw would otherwise defeat the browser's dblclick, which
+ needs both clicks on the same element) — so remove now works whether or not the
+ point was already selected.
+
+- **Help: the `?` overlay now documents lines, curves & motion paths.** New
+ "Lines & curves" and "Motion paths" sections spell out the gestures — draw from
+ the Shape menu, drag points, click a point for bézier handles, Alt for a sharp
+ corner, double-click to add/remove a point, scroll a motion-path point to set
+ its speed.
## [1.0.6] — 2026-07-21
diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.ts
index bc6f60a1..67455dfb 100644
--- a/slides/src/editor/editor.ts
+++ b/slides/src/editor/editor.ts
@@ -1677,6 +1677,20 @@ export class Editor {
['C', t('Comment mode')],
['?', t('This help')],
])
+ section(t('Lines & curves'), [
+ [t('Shape ▾'), t('Draw a line, curved line or connector — then drag on the canvas')],
+ [t('Drag a point'), t('Move an endpoint or anchor; drag the body to move the whole line')],
+ [t('Click a point'), t('Reveal its bézier handles for a precise curve')],
+ [`${t('Alt')}-${t('drag')}`, t('Break a smooth point into a sharp corner')],
+ [t('Double-click'), t('Add a point on the line; double-click a point to remove it')],
+ ])
+ section(t('Motion paths'), [
+ [t('Presenting ▸ Loop'), t('Give an element a motion-path loop, then Edit path on canvas')],
+ [t('Drag points'), t('Shape the trajectory — the first point is the element’s rest spot')],
+ [t('Click a point'), t('Reveal bézier handles; Alt-drag one for a sharp corner')],
+ [t('Double-click'), t('Add a point on the path; double-click a point to remove it')],
+ [t('Scroll a point'), t('Set how fast the element moves through that point')],
+ ])
section(t('Presenting'), [
['F5', t('Present')],
['F', t('Toggle fullscreen while presenting')],
diff --git a/slides/src/editor/patheditor.ts b/slides/src/editor/patheditor.ts
index 648a3029..805983b0 100644
--- a/slides/src/editor/patheditor.ts
+++ b/slides/src/editor/patheditor.ts
@@ -212,6 +212,11 @@ export class PathEditor {
private elId = ''
private scale = () => 1
private dirty = false
+ // Manual double-click detection for nodes: the DOM `dblclick` can't be used on
+ // anchors because selecting one redraws the overlay between the two clicks
+ // (destroying the shared target), so we track the last node mousedown here.
+ private lastDown = { idx: -2, t: 0 }
+ private suppressDbl = false
constructor(
private scaleHost: HTMLElement,
@@ -263,6 +268,7 @@ export class PathEditor {
svg.addEventListener('dblclick', (ev) => this.onDblClick(ev))
// click empty space to deselect (hide handles)
svg.addEventListener('mousedown', (ev) => {
+ this.suppressDbl = false // fresh gesture on empty canvas — clear any stale suppress
if (ev.target === svg && this.selected !== null) { this.selected = null; this.draw() }
})
this.scaleHost.appendChild(svg)
@@ -471,9 +477,33 @@ export class PathEditor {
return { x: (ev.clientX - rect.left) / s, y: (ev.clientY - rect.top) / s }
}
+ /** Remove waypoint `idx` (keeps at least two), keeping speeds + selection aligned. */
+ private removeNode(idx: number) {
+ if (this.nodes.length <= 2) return
+ this.nodes.splice(idx, 1)
+ this.speeds.splice(idx, 1)
+ if (this.selected !== null) {
+ if (this.selected === idx) this.selected = null
+ else if (this.selected > idx) this.selected--
+ }
+ this.dirty = true
+ this.draw()
+ }
+
private dragAnchor(down: MouseEvent, idx: number) {
down.stopPropagation()
down.preventDefault()
+ // Second mousedown on the same node within the double-click window = remove.
+ // (We detect it here rather than via the DOM `dblclick`, which the
+ // select-redraw below would otherwise defeat — see `lastDown`.)
+ if (idx === this.lastDown.idx && down.timeStamp - this.lastDown.t < 400) {
+ this.lastDown.idx = -2
+ this.suppressDbl = true // swallow the trailing DOM dblclick so it can't also insert
+ this.removeNode(idx)
+ return
+ }
+ this.lastDown = { idx, t: down.timeStamp }
+ this.suppressDbl = false // fresh gesture — any stale suppress is void
// selecting a waypoint reveals its handles
if (this.selected !== idx) { this.selected = idx; this.draw() }
const startPt = this.toSlide(down)
@@ -568,23 +598,15 @@ export class PathEditor {
private onDblClick(ev: MouseEvent) {
ev.preventDefault()
ev.stopPropagation()
+ // A double-click that already removed a node (handled in dragAnchor) must not
+ // fall through and insert a point where the node used to be.
+ if (this.suppressDbl) { this.suppressDbl = false; return }
const target = ev.target as Element
const q = this.toSlide(ev)
- if (target.classList.contains('ed-pe-anchor')) {
- // remove (keep at least two)
- const idx = Number((target as SVGElement).dataset.idx)
- if (this.nodes.length > 2) {
- this.nodes.splice(idx, 1)
- this.speeds.splice(idx, 1)
- if (this.selected !== null) {
- if (this.selected === idx) this.selected = null
- else if (this.selected > idx) this.selected--
- }
- this.dirty = true
- }
- this.draw()
- return
- }
+ // Node removal is handled manually in dragAnchor (the select-redraw defeats a
+ // DOM dblclick on the anchor); a dblclick that still lands on a node is a
+ // stale target after that redraw — ignore it rather than mis-insert.
+ if (target.classList.contains('ed-pe-anchor')) return
if (target.classList.contains('ed-pe-hit')) {
// insert on the nearest segment via de Casteljau split — the split
// preserves the trajectory shape EXACTLY (sub-pixel), and the three