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

@exnext/rotatex

v1.0.5

Published

Library to make circular menu, list, etc. (...and everything what you want)

Downloads

11

Readme

rotatex

Library to make circular menu, list, etc. (...and everything what you want)

Live demo

Live demo

NPM

npm install @exnext/rotatex

Initialization

To use rotatex library you must include required rotatex.css to your project and optional rotatex.js if you would like to use some additional features.

<link href="rotatex.css" rel="stylesheet">
<script type='text/javascript' src='rotatex.js'></script>

or

import '@exnext/rotatex/dist/rotatex.css';
import { Rotatex } from '@exnext/rotatex';

Usage based only on rotatex.css

To set your circular menu you may use css classes and css variables

Main element

Main element should have set rotatex class to enable the library.

Children

Every child element should have set classes from r-0 to r-360 or --angle variable.

  • classes from r-0 to r-360 describe an angle of rotation

  • r-off class is for setting excluded items

  • by --angle variable you can set angle

  • using --offset-angle you can set offset for an angle. Great for menu rotation by routing on any SPA framework or other situation. To rotate all menu you can use also --main-offset-angle variable with main element instead --offset-angle on all children. But be careful, --main-offset-angle is set by Rotatex javascript class and they shouldn't be used togather.

Examples

Rotating by class name from r-0 to r-360 or by --angle css variable

<ul class="rotatex">
    <li class="r-0"><span>Test 1</span></li>
    <li class="r-60"><span>Test 2</span></li>
    <li class="r-120"><span>Test 3</span></li>

    <li style="--angle: 180deg;"><span>Test 4</span></li>
    <li style="--angle: 240deg;"><span>Test 5</span></li>
    <li style="--angle: 300deg;"><span>Test 6</span></li>
</ul>

Excludes

If you want to set any item in the list other than the rest, e.g. by always placing it in the middle position, you can use the r-off class.

<ul class="rotatex">
    <li class="r-off your-class"><span>Menu</span></li>

    <li class="r-0"><span>Test 1</span></li>
    <li class="r-120"><span>Test 3</span></li>
    <li class="r-240"><span>Test 5</span></li>
</ul>

Animation

To animate rotation use rotatex-rotate class and one of classes to set direction of rotation: rotatex-rotate__left or rotatex-rotate__right.

<ul class="rotatex rotatex-rotate rotatex-rotate__left">
    <li class="r-0"><span>Test 1</span></li>
    <!-- ...and more items -->
</ul>

To change time of animation or other you should use css parameters.

Usage based also on rotatex.js

This is simple usage of Rotatex javascript class. You haven't to set css rotatex class. It will be set by constructor. You can use Rotatex javascript class with static menu if you would like to use actions and events.

<ul id="dynamic"></ul>

<script>
    let rotatex = new Rotatex('#dynamic');

    for (i = 1; i <= 10; i++) {
    let span = document.createElement('span');
    span.innerText = 'Test ' + i;

    let li = document.createElement('li');
    li.appendChild(span);

    rotatex.Element.appendChild(li);
    } 
</script>

Constructor

  • element - main element using rotatex library. It should be an HTMLElement object or a valid CSS selector string
  • options - few options described below
class Rotatex {
    constructor(element: HTMLElement | string, options?: RotatexOptions | undefined);
}

interface RotatexOptions {
    rotateByAngle: number;
    rotateLimit?: number;
}

Rotating by the mouse wheel or finger on the touch screen actions

To rotate the list with the mouse wheel or finger on the touch screen, set the rotateByAngle option. The list will rotate clockwise.

let rotatex = new Rotatex(ul, { rotateByAngle: 10 });

Set a negative value for counterclockwise rotateByAngle.

let rotatex = new Rotatex(ul, { rotateByAngle: -10 });

Infinity rotation is forbidden. To set limit angle rotation you may set rotateLimit option. Default value is 360000 deg.

let rotatex = new Rotatex(ul, { rotateByAngle: 10, rotateLimit: 360 });

Events

The mouse wheel or finger on the touch screen triggers rotate event.

let rotatex = new Rotatex(ul, { rotateByAngle: 10 });

rotatex.on('rotate', (event) => {
    console.log(event);
});

Parameter of callback is RotateDataEvent type and include information:

interface RotateChild {
    element: HTMLElement,
    angle?: number;
}

interface RotateDataEvent {
    mainOffsetAngle: number;
    children: RotateChild[]
}

Public properties

class Rotatex {
    /* Return the connected main element */
    get Element(): HTMLElement;

    /* Change a rotation by code like during mouse and touchscreen actions */
    rotate(delta: number): void;

    /* Set an absolute rotation */
    setRotation(delta: number): void;

    /* Return information about all children elements with its angle */
    getChildrenDetails(): RotateChild[];
}