GithubHelp home page GithubHelp logo

circlejs's Introduction

circle.js

circle.js is a dependency-free JavaScript ES6 circle component. All items are aligned in a circle and can be rotated and resized. Optionally you can add a connection line to connect each item. A perfect module to highlight your key features.

Getting started

Pull-in a latest version with NPM ...

npm install @tobidemski/circlejs

... provide <link> to the required core stylesheet.

<!-- Required Core stylesheet -->
<link rel="stylesheet" href="node_modules/@tobidemski/circlejs/dist/css/circlejs.core.min.css">

... then, prepare a little bit of necessary markup ...

<div class="circle example-circle">
    <div class="circle__items">
        <div class="circle__item circle__item--center">
            Item 1
        </div>
        <div class="circle__item circle__item--center">
            Item 2
        </div>
        <div class="circle__item circle__item--center">
            Item 3
        </div>
    </div>
    <!-- Optionally if you want to connect each circle item with a line -->
    <div class="circle__connections"></div>
    <!-- Optionally if you want to have a circle background in the size of the diameter -->
    <div class="circle__background"></div>
</div>

... and finally, initialize circlejs.

import circle from '@tobidemski/circlejs'

new circle('.example-circle');

Advanced

import circle from '@tobidemski/circlejs'

let options = {
  startAngle: 'top',
  clockwise: false,
  center: 'full-center',
  enableRotation: true
}

let circle = new circle('.example-circle', options);

/**
 * Event which gets triggered if a new item is added.
 * @param {any} data
 * data.item: new added item
 * data.length: total items count
 */
circle.on('item.added', function (data) {
  data.item.textContent = `Item ${data.length}`;
});
        
circle.add(); // Adds a new circle item

See more in Wiki

Result

3 Items with connections

3 items result

4 Items with connections

4 items result

5 Items with connections

5 items result

Contributing

Feel free to contribute to this module.

Browser Support

  • Chrome
  • Edge
  • Firefox

Building

Build using NPM scripts. The following scripts are available:

  • build:css - Outputs CSS files from SASS files.
  • build:js - Outputs all destination variants of the script.
  • build - Comprehensively builds the entire library.
  • run:examples-server - Starts a simple node.js express server to see some examples.

Todos

  • Bug: Changing the direction while rotating loses the current position and jumps to the new calculated position
  • Bug: Changing the speed of rotation while rotating loses the current position and jumps to the new calculated position

Credits

License

Copyright (c) 2022-present, Tobi Demski. Licensed under the terms of the MIT License.

circlejs's People

Contributors

tobidemski avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.