Socket
Book a DemoInstallSign in
Socket

@afiniti/webgl-slider

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@afiniti/webgl-slider

React component for webgl slider for videos and images

0.0.4
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

@afiniti/webgl-slider

Description

React slider component for images and videos. It provides option for webgl effects for sliding animations.

Requirements

Currently, works only for images and videos.

Installation

npm i @afiniti/webgl-slider

Features

  • Fullscreen slider
  • Handles both images and videos.
  • Webgl transition effects.
  • Multiple callbacks for as much customization as possible

Props

NameTypeDescription
fpsnumberIn order to keep performance in mind if it is a video carousel then use your desired fps to keep memory and cpu usage as less as possible. Defaults to null it will collect browser refresh rate.
dataobjectImage or video sources in specified format.
effectnumberCurrently 8 different types of webgl effects are available pass number between 1 to 8.
iterationsnumberNumber of iterations in case of autoplay. Defaults to infinite/null
autoplayboolAutoplay slider or not. Defaults to true
autoplaySpeednumberSet autoplay slide speed . Defaults to 3000 3 seconds
slideSpeedfloatSet slide effect speed. Defaults to 1.6 1.6 seconds
scrollToSlideboolChange slides on mouse/trackpad scroll. Defaults to false.
initialSlideIndexnumberOptional value in pixels if fixed height needs to be added to image elements.

Methods

NameArgsDescription
pausenonePause the autoplay.
resumenoneStart the autoplay.
pauseRendernonePause requestanimationframe to save battery and memory.
resumeRendernoneResume requestanimationframe.
SlideNextnoneGo to the next slide.
slidePreviousnoneGo to the previous slide.
updateScrollToSlidetrue/falseEnable/Disable slides Change on mouse/trackpad scroll

Callbacks

NameDescription
onSlideStartreturns currentIndex, nextIndex, direction, Triggers on slide start
onSlideCompletereturns nothing, Trigger when slide ends
webglSliderApireturn ref of the slider to give access to all available methods

Example Usage

The package can be integrated inside a react component as follows:

import React from 'react';
import WebglSlider from '@afiniti/webgl-slider';

const data={
  {Picturehandle: "https://images.unsplash.com/photo-1603993097397-89c963e325c7?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80"},
  {Picturehandle: "https://images.unsplash.com/photo-1618580987827-8d73bdd196aa?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1489&q=80"},
  {Picturehandle: "https://images.unsplash.com/photo-1593642632823-8f785ba67e45?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1489&q=80"}
};

OR

const data={
  {videoHandle: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"},
  {videoHandle: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"},
  {videoHandle: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"}
};

// you can get public test videos from here: https://gist.github.com/jsturgis/3b19447b304616f18657

const Component = () => {
  return (
    <WebglSlider
      fps={25}
      autoplay
      effect={4} // give number between 1 to 8
      iterations={2}
      slideSpeed={1.6}
      data={webglData}
      autoplaySpeed={8000}
      initialSlideIndex={0}
      onSlideStart={(currentIndex, nextIndex, direction) => {
        console.log(currentIndex, nextIndex, direction);
      }}
      onSlideComplete={() => {
        console.log('complete');
      }}
      webglSliderApi={ref => {
        // get access to slider's methods
        console.log('ref', ref);
      }}
    />
  );
};

export default Component;

Keywords

webgl-slider

FAQs

Package last updated on 24 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.