Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

offset anchors towards facing direction

See original GitHub issue

Is your feature request related to a problem? Please describe. When a straight arrow is anchored to a circular/round element, neither middle nor auto is a preferable choice.

Describe the solution you’d like It would be nice if there were a variant of middle where you could provide a radius offset where the arrow would point towards the middle of the target element, but is radius-amount shorter.

Of course, this type of anchor would only really be useful on straight arrows.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

Eliav2commented, Sep 1, 2021

understood, you are right and this is planned for the next release. will leave this issue open as a feature request until the next release that solves this.

sillydan1commented, Sep 16, 2021

For anyone interested, this is how I ended up sidestepping this issue (please excuse the messy code) note that this code is not very performant:

import React, {Component} from "react";
import Xarrow from "react-xarrows";
import * as ReactDOM from "react-dom";

class Edge extends Component {
    state = {
        startOffset: {},
        endOffset: {}

    dist(a, b) {
        return Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2);

    calculateOffset(startId, endId) {
        let start_el = document.getElementById(startId);
        let end_el = document.getElementById(endId);
        if(start_el === null || end_el === null)
            return {x:0, y:0};
        let start_box = start_el.getBoundingClientRect();
        let end_box = end_el.getBoundingClientRect();
        let start = {x: start_box.x + start_box.width/2, y: start_box.y + start_box.height/2};
        let end = {x: end_box.x + end_box.width/2, y: end_box.y + end_box.height/2};
        let radius = end_box.width / 2;
        let directionMagnitude = this.dist(start, end);
        if(directionMagnitude === 0)
            return {x:0, y:0};
        let directionNormalized = {
            x: (start.x - end.x) / directionMagnitude,
            y: (start.y - end.y) / directionMagnitude
        return {
            x: (directionNormalized.x * radius),
            y: (directionNormalized.y * radius)

    updateOffsets = () => {
        const startOffset = this.props.startAnchor === 'middle' ? this.calculateOffset(this.props.end, this.props.start) : {x: 0, y: 0};
        const endOffset = this.props.endAnchor === 'middle' ? this.calculateOffset(this.props.start, this.props.end) : {x: 0, y: 0};
            startOffset: startOffset,
            endOffset: endOffset

    componentDidMount() {
        // TODO: Once react-xarrows supports anchors with offset in facing direction, use that instead.
        ReactDOM.findDOMNode(this).addEventListener("DOMAttrModified", this.updateOffsets.bind(this));

    render() {
        const {start, end, id, startAnchor, endAnchor} = this.props;
        return (
            <Xarrow start={start}
                        position: startAnchor,
                        offset: this.state.startOffset
                        position: endAnchor,
                        offset: this.state.endOffset

export default Edge;
Read more comments on GitHub >

github_iconTop Results From Across the Web

offset-anchor - CSS: Cascading Style Sheets - MDN Web Docs
The offset-anchor CSS property specifies the point inside the box of an element traveling along an offset-path that is actually moving along ...
Read more >
Offset anchor bolt and method of orientation
The anchor bolt is formed with an offset so that a substantial portion of the embedded portion of the anchor bolt is at...
Read more >
Horizontal wales may be used to connect the ground anchors to the driven soldier beams. Horizontal wales can be installed on the face...
Read more >
Offsetting or extruding faces
Select the Pull · Select the face or surface you want to offset or extrude. · (Optional) Add edges to your selection. ·...
Read more >
Move a layer's anchor point in Motion - Apple Support
If you rotate a layer, it spins around this central anchor point. If you offset the anchor point, however, the layer no longer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found