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 🙏

© 2026 – Pkg Stats / Ryan Hefner

css-navigation-library

v1.0.3

Published

Navigation library based on css, javascript and global variables

Readme

css-navigation-library

npm version Navigation library for the lovers of css based on javascript😊


  1. Example
  2. Usage
  3. Angular Implementation
  4. Already tested on
  5. Comming soon

Examples

Horizontal Carousels

ezgif com-gif-maker

Vertical Carousels

ezgif com-gif-maker (1)

Grid Carousels

ezgif com-gif-maker (2)

Multiple Carousels

ezgif com-gif-maker (3)

Usage


Initialization

  1. Add the src files in the project
  2. Implement the styles.scss at the root of the app
  3. Initialize the main somewhere at the root of the app
import { init } from "../assets/src/main.js";
export class AppComponent {
  ...
  constructor() {
    init() // Initialize navigation library
  }
}

Implementing carousels + focusable elements

‼️ All the focusable elements should have a .focusable-element class wrapped by a .carousel-container class

‼️ All the grid carousels should have a .carousel-container-row class by row and all the rows should be wrapped by a .carousel-container class


Global variables usage

Global variable | Usage | Type of | Initial value ------------- | ------------- | -------------| ------------- actualHorizontal | Actual index on horizontal position | Number | 0 actualVertical | Actual index on vertical position | Number | 0 isInNormalCarousel | Current carousel is horizontal or vertical | Boolean | true isInGridCarousel | Current carousel is a grid | Boolean | false actualGridRow | Actual index on grid row | Number | 0 actualGridCell | Actual index on row cell | Number | 0 childrenBetweenUp | Access a diferent carousel on way up | Boolean | false childrenBetweenDown | Access a diferent carousel on way down | Boolean | false childrenBetweenLeft | Access a diferent carousel on way left | Boolean | false childrenBetweenRight | Access a diferent carousel on way right | Boolean | false goBack | Go back key number | Number | 8

Angular Implementation


  1. Use the (focus) event on html .carousel-container elements to set the needed values for the type of carousel
   <div class="carousel-container" (focus)="setCarouselType()"></div>
  /**
   * Navigation - .ts file
   */
  setCarouselType(): void {
    window.isInGridCarousel = true;
    window.isInNormalCarousel = false;
  }
  1. Use the (keydown) event on html .focusable-element elements for horizontal movement for normal carousels and set the [ngStyle]="move"
  • The key down listens to the current key and updates the css
  • The keyDown function receives the cardWidth to do the exact movement of the carousel
  • The move attribute gets the movement to the right of the carousel
<div class="carousel-container">
    <div
      tabindex="0"
      class="focusable-element"
      (keydown)="keyDown($event, cardWidth)"
      [ngStyle]="move"
    >
      <div class="card" [style.backgroundColor]="color">
        <h1>{{color}}</h1>
      </div>
</div>
  // Navigation
  move = {
    right: '',
  };
  
  keyDown(e: any, cardWidth: number) {
    const cardRealSize = cardWidth;

    // Right arrow
    if (e.keyCode === 39) {
      // If not is infinite carousel and user is not on the last card
      if (window.actualHorizontal < this.container.length - 1) {
        window.actualHorizontal += 1;
        // Move the css and focus next card
        this.move.right = `${cardWidth * window.actualHorizontal}vw`;
      }
    }
    // Left arrow
    else if (e.keyCode === 37) {
      // If not is infinite carousel and user is not on the first card
      if (!this.isInfiniteCarousel && window.actualHorizontal > 0) {
        window.actualHorizontal -= 1;
        // Move the css and focus next card
        this.move.right = `${cardWidth * window.actualHorizontal}vw`;
      }
    }
  }
  1. Use the (keydown) event on html .focusable-element elements for horizontal movement for infinite carousels
  • The container is the list of elements that are rendered on the carousel
<div class="carousel-container">
    <div
      tabindex="0"
      class="focusable-element"
      (keydown)="keyDown($event)"
    >
      <div class="card" [style.backgroundColor]="color">
        <h1>{{color}}</h1>
      </div>
</div>
  keyDown(e: any) {
    // Right arrow
    if (e.keyCode === 39) {
      // Get first element and add it to last position (circular behaviour)
      const firstElement = this.container?.shift();
      this.container?.push(firstElement);
    }
    // Left arrow
    else if (e.keyCode === 37) {
      // Get last element and add it to first position (circular behaviour)
      const lastElement = this.container?.pop();
      this.container?.unshift(lastElement);
    }
  }

‼️ For a more detailed usage go to usage-examples/angular-example

npm install
npm start
Project should be running on http://localhost:4200/ or selected port

✅ Already tested on


  • [X] Samsung (2017-2021)
  • [X] LG (2017-2021)
  • [X] Vizio (series D and V)

👉 Currently used on aha smarttvs platforms https://www.aha.video/


🔜 Comming Soon


  • [ ] React implementation documentation and example

© 2022, Andrea Amaya
License: MIT