npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@omnedia/ngx-connection-beam

v2.0.0

Published

A simple component library to connect elements with an animated beam.

Downloads

137

Readme

ngx-connection-beam

@omnedia/ngx-connection-beam is an Angular component that dynamically renders animated connection lines between two elements. With customizable curvature, colors, and animation settings, it creates visually striking connection beams between any two elements in your Angular application.

Features

  • Dynamic Paths: Automatically calculates and draws a smooth path between two HTML elements, with customizable curvature.
  • Customizable Appearance: Control the beam’s color, width, opacity, and gradient, allowing for a wide range of visual effects.
  • Smooth Animations: Animate the connection beams with customizable duration and delay, making them perfect for drawing attention to interactions or flows.
  • Viewport-Aware: The component updates its dimensions and position in response to window resizing to maintain accuracy.

Installation

Install the library using npm:

npm install @omnedia/ngx-connection-beam

Usage

Import the NgxConnectionBeamComponent in your Angular module or component:

import { NgxConnectionBeamComponent } from '@omnedia/ngx-connection-beam';

@Component({
  ...
  imports: [
    ...
    NgxConnectionBeamComponent,
  ],
  ...
})

Use the component in your template:

<div class="wrapper">
    <div #elementA></div>
    <div #elementB></div>

    <om-connection-beam
    [fromRef]="elementA"
    [toRef]="elementB"
    [curvature]="50"
    [pathColor]="'#ff5733'"
    [pathWidth]="3"
    [duration]="6"
    [gradientStartColor]="'#ffcc00'"
    [gradientStopColor]="'#3498db'"
    >
    </om-connection-beam>
</div>

How It Works

  • Connection Line Between Elements: NgxConnectionBeamComponent connects two specified elements using an SVG path. This path is dynamically calculated based on the relative positions of the two elements, ensuring that the connection remains intact even if the window is resized.
  • Smooth Animations: The connection beam can be animated using cubic easing, making the appearance of the connection more fluid and engaging.
  • Customizable Gradient: With support for linear gradients, the connection beam can transition between colors for a dynamic, visually engaging effect.

API

<om-connection-beam
  [fromRef]="fromElement"
  [toRef]="toElement"
  [curvature]="curvature"
  [pathColor]="pathColor"
  [pathWidth]="pathWidth"
  [pathOpacity]="pathOpacity"
  [gradientStartColor]="gradientStartColor"
  [gradientStopColor]="gradientStopColor"
  [duration]="duration"
  [delay]="delay"
  [reverse]="reverse"
  [startXOffset]="startXOffset"
  [startYOffset]="startYOffset"
  [endXOffset]="endXOffset"
  [endYOffset]="endYOffset"
>
</om-connection-beam>
  • fromRef (required): A reference to the HTML element where the connection starts.
  • toRef (required): A reference to the HTML element where the connection ends.
  • curvature (optional): Curvature of the beam, defining how much the path curves between the two points. Defaults to 0.
  • pathColor (optional): The color of the connection path. Defaults to 'gray'.
  • pathWidth (optional): The width of the connection path. Defaults to 2px.
  • pathOpacity (optional): The opacity of the connection path. Defaults to 0.2.
  • gradientStartColor (optional): The color at the start of the gradient. Defaults to '#ffaa40'.
  • gradientStopColor (optional): The color at the end of the gradient. Defaults to '#9c40ff'.
  • duration (optional): Duration of the animation in seconds. Defaults to a random value between 4 and 7.
  • delay (optional): Delay before the animation starts, in seconds. Defaults to 0.
  • reverse (optional): Reverses the direction of the gradient animation. Defaults to false.
  • startXOffset, startYOffset, endXOffset, endYOffset (optional): Offsets to fine-tune the start and end positions of the beam relative to the elements.

Example

<div class="wrapper">
    <div #startElement></div>
    <div #endElement></div>

    <om-connection-beam
    [fromRef]="startElement"
    [toRef]="endElement"
    [curvature]="100"
    [pathColor]="'#e74c3c'"
    [gradientStartColor]="'#e74c3c'"
    [gradientStopColor]="'#9b59b6'"
    [duration]="5"
    [reverse]="true"
    >
    </om-connection-beam>
</div>

This example draws a curved connection beam between two elements with a red-to-purple gradient that animates over 5 seconds.

Contributing

Contributions are welcome. Please submit a pull request or open an issue to discuss your ideas.

License

This project is licensed under the MIT License.