Pitfalls

Sorted by what you see. Each entry links to the section that explains it.

Something doesn’t update

  • A block never runs again. One of its senders is a plain object, number or array, which can’t announce changes. Pass the reactive object. → What can be a sender
  • A block shows an old value. It reads something it doesn’t list as a sender. List everything it reads that can change. → What can be a sender
  • A block combines a new value with an old one. It lists a value and something derived from it as senders, and ran before the change reached the derived one. If every change reaches the end of the chain, list only that. → One update at a time
  • Reactive.do([...shape], …) misses changes. Helpers and attachments write the shape as a whole, not its points one by one. Depend on the shape: Reactive.do([shape], …). → Shapes: depend on the shape
  • An attachment to a polygon or polyline doesn’t follow its corners. Shapes built from a list of vertices aren’t linked to them. Call Reactive.linkVertices(shape). → Shapes: depend on the shape
  • Changing a field of an item changes nothing. Assign a new object, or call Reactive.emit(item). → Changes VisQuill can’t see
  • A circle made with circleAt stays behind when its center moves. It was computed once. Attach it: Attach.circleToPoint(circle, center). → Shapes that helpers fill in
  • A point visual doesn’t move with the point it was made from. visuals.point(style, p) copies p. Use the visual itself as the point and write into it. → Shapes that helpers fill in
  • A shape built from [x, y] doesn’t follow anything. Arrays are copied. Pass point objects. → Plain numbers and arrays

Something has the wrong value, or jumps

  • A constraint doesn’t hold for everyone. Blocks that ran before it in the same update kept the old value. Register the constraint right after the object it constrains. → One update at a time
  • A dependent briefly sees a half-moved point. p.x = …; p.y = … is two updates. Wrap them in Reactive.block. → Several changes, one update
  • A value you set is overwritten. It has another writer: an attachment, a second attachment, or a running animation. Give every object one writer. → One writer per object, One animation per value
  • An animation takes far too long or too short. Durations and delays are in milliseconds. → Easing to a target

Something is in the wrong place

  • A handle can’t be grabbed. Something created later lies on top of it. Set canvas.handles.defaultZIndex = 1 before creating handles. → Drawing order
  • Converted coordinates are off. toGraphic and fromGraphic on a visual work in that visual’s own coordinates. Ask the group instead: group.toGraphic(p). → A coordinate system of its own
  • Text is upside down, or doesn’t turn. Labels follow their direction and flip to stay readable; the long form of label and labelAt switches both. → Turning

Something looks wrong

  • visual.visible = false does nothing. visible is a reactive value: visual.visible.value = false. → The kinds of values
  • A style class has no effect. It got the prefixes of the graphic and its layers: "bar" in layer chart- is vqg-chart-bar. Use a leading dot for names without a prefix. → How class names are built
  • A second @style removed the first. @style sets the whole inline style. Write all inline properties each time. → Inline styles
  • Classes are gone after setting class on the element. setAttribute("class", …) replaces what VisQuill set. Use applyStyleDirective with @class and @class-remove. → Changing the look