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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-drag-guide-lines

v1.1.1

Published

Adds guide lines to react draggable components

Downloads

212

Readme

React drag guide lines

A React Library to enable draglines for perfect placement of draggable items

You can check the demo here

Usage

using npm

npm i -S react-drag-guide-lines

using yarn

yarn add -S react-drag-guide-lines

Parent Component

Add the following import to your parent component

Parent import

import { ReactAlignLinesContainer } from 'react-drag-guide-lines';

Parent code

instead of your parent you can wrap your draggable children with the following code

return (
  <ReactAlignLinesContainer styles={{...yourprops}}>
    {draggableComponents.map(item => <YourComponent {...props}>)}
  </ReactAlignLinesContainer>
)

Parent Props

| Title | About | Required | type | Values | Default Values | | --------------- | ------------------------- | -------- | ----------------------------------- | ---------------------- | ---------- | | emptyState | Empty state component if there are no children, shows up when showEmptyState is true or children is empty list | true |ReactNode | ReactNode| undefined | | showEmptyState (depricated) | boolean to check if we need to show empty state or not | false | boolean | true, false | false | | limit | Limit the lines to the boundaries | false |boolean | true, false | false | | styles | Styles for the wrapper, horizontal Lines and Vertical Lines | false | styles | values | undefined | | directions | when the item is dragged it specifies when to show the draglines | false | string[] | sub array of ['tt', 'bb', 'll', 'rr', 'hc', 'wc', 'lr', 'rl', 'tb', 'bt'] | ['tt', 'bb', 'll', 'rr', 'hc', 'wc', 'lr', 'rl', 'tb', 'bt'] more here|

Styles

Styles required to pass from parent for different styles like backgroundColor, width or height

Type
{
  wrapper?: React.CSSProperties,
  xLineStyle?: React.CSSProperties,
  yLineStyle?: React.CSSProperties,
}
Default Values
{
  wrapper: { ...wrapperStyles },
  xLineStyle: { ...horizontalStyles },
  yLineStyle: { ...verticalStyles },
}
Directions

directions is a collection of array which specifies when to show the drag lines.

values are collection of the bottom options provided.

possible values

| option | explanation | | ----------- | ----------------- | | tt | top of the dragging element and top of the relative elements | | bb | bottom of the dragging element and bottom of the relative elements | | ll | left side of the dragging element and left of the relative elements | | rr | right side of the dragging element and right of the relative elements | | hc | center of heights of dragging element and the relative elements | | wc | center of widths of dragging element and the relative elements | | lr | left of the dragging element and the right of the relative element | | rl | right of the dragging element and the left of the relative elements | | tb | top of the dragging element and the bottom of the relative element | | bt | bottom of the dragging element and the top of the relative element |

example

directions: ['tt', 'bb', 'll', 'rr', 'hc', 'wc', 'lr', 'rl', 'tb', 'bt']

Child Component

import

import { IDragOperations } from 'react-drag-guide-lines';

Props

to your props you can add a new Prop dragOperations with IDragOperations as type

interface IChildProps {
  // your props
  dragOperations?: IDragOperations
}

Child Code

add data-x and data-y props to your child props and use the functions of IDragOperations appropriately

const ChildComponent = (props: IChildProps) => {
  const {  dragOperations, ...rest } = props;

  // call this function when you end dragging
  const handleDragEnd = () => {
        // your code
        dragOperations?.onDragStop();
    };

    // call this function when you start dragging
    const handleDragStart = () => {
        // Your code
        dragOperations?.onDragStart();
    };

    // call this function when you are dragging
    const handleDragging = () => {
        // Your code
        // dragX - difference between current x position and previous x position
        // dragY - difference between current y position and previous y position
        dragOperations?.onDrag({ x: dragX, y: dragY });
    };

    return (
        <DragComponent
          // your props
          data-x={currentXPosition}
          data-y={currentYPosition}
        />
    );
}

export default ChildComponent;

You can check the example code here

Made with love in India