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

coherent-gameface-slider

v4.0.1

Published

A component for Coherent Labs Gameface.

Downloads

105

Readme

The gameface-slider is part of the Gameface custom components suite. As most of the components in this suite it uses slots to allow dynamic content.

Installation

npm i coherent-gameface-slider

Usage with UMD:

  • add the gameface-slider component to your html:
<gameface-slider class="gameface-slider-component"></gameface-slider>

This is all! Load the file in Gameface to see the gameface-slider.

Usage with JavaScript:

If you wish to import the Slider using JavaScript you can remove the script tag and import it like this:

import { Slider } from 'coherent-gameface-slider';

or simply

import 'coherent-gameface-slider';

Note that this approach requires a module bundler like Webpack or Rollup to resolve the modules from the node_modules folder.

Add the Styles

<link rel="stylesheet" href="coherent-gameface-components-theme.css">
<link rel="stylesheet" href="styles/horizontal.css">
<link rel="stylesheet" href="styles/vertical.css">

To overwrite the default styles, simply create new rules for the class names that you wish to change and include them after the default styles.

Updating the slider's state

You are able to dynamically update the slider state for the following properties:

  • orientation - How the slider is oriented. Either 'horizontal' or 'vertical'.
  • step - The scroll step of the slider that is used when scrolling with the mouse. The value provided should be a number. Negative values are also accepted and they can be used to invert the scroll direction.

You can set them via setAttribute or directly using the setters like slider.orientation = 'horizontal'.

For example:

const slider = document.querySelector('gameface-slider');

slider.orientation = 'horizontal'; // or 'vertical'. If the passed value is not supported - the slider will fallback to default one - 'vertical'
// Or
slider.setAttribute('orientation', 'horizontal');

slider.step = 20; // If you want to invert the mouse wheel you can set negative value. For example -20.
// Or
slider.setAttribute('step', '20');

You can get the current orientation or step in the following way:

console.log(slider.orientation);
console.log(slider.step);

You can also update the current handle position of the slider using the scrollTo method. It receives one argument that is the new position of the handle in percent.

slider.scrollTo(50); // Will set the handle to position that is 50% of the available scroll bar area.

Events

The scrollTo method dispatches a custom slider-scroll event, which can be listened to if something needs to be done on scroll

document.querySelector('gameface-slider').addEventListener('slider-scroll', (event) => {
    const newHandlePosition = event.detail.handlePosition; // The new handle position
    //Do something here
})