Giter Club home page Giter Club logo

react-glider's Introduction

build

react-glider

A ReactJS wrapper for Glider.js.

Quick Start

Installation:

npm i -s react-glider

Usage

import * as React from 'react';

import Glider from 'react-glider';
import 'glider-js/glider.min.css';
<Glider
  draggable
  hasArrows
  hasDots
  slidesToShow={2}
  slidesToScroll={1}
>
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
</Glider>

CSS

To use the CSS for Glider.js, you may import it from the npm module:

import "glider-js/glider.min.css";

or reference the CSS file in your <head> (not recommended):

<link
  rel="stylesheet"
  href="https://unpkg.com/[email protected]/glider.min.css"
/>

Demo Defaults

This package also exposes the CSS used to render the demo which may also be imported as follows.

Note that this file is no longer maintained.

import Glider from "react-glider/glider.defaults.css";

Options

Option Description
hasArrows Show/hide arrows. (default = false)
hasDots Show/hide dots. (default = false)
iconLeft ReactNode for the left arrow. (default = '«')
iconRight ReactNode for the right arrow. (default = '»')
scrollToSlide Starting slide (default = 0)
scrollToPage Starting page (default = 0)
slidesToShow The number of slides to show in container. If this value is set to auto, it will be automatically calculated based upon the number of items able to fit within the container viewport. This requires setting the itemWidth option.
slidesToScroll The number of slides to scroll when arrow navigation is used. If this value is set to auto, it will match the value of slidesToScroll.
itemWidth This value is ignored unless slidesToShow is set to auto, in which it is then required.
exactWidth This prevents resizing items to fit when slidesToShow is set to auto.
resizeLock If true, Glider.js will lock to the nearest slide on resizing of the window
rewind If true, Glider.js will scroll to the beginning/end when its respective endpoint is reached
duration An aggravator used to control animation speed. Higher is slower. (default = 0.5)
dots A string containing the dot container selector
arrows An object containing the prev/next arrows selectors
draggable If true, the list can be scrolled by click and dragging with the mouse. (default = false)
dragVelocity How much to aggravate the velocity of the mouse dragging. (default = 3.3)
scrollPropagate Whether or not to release the scroll events from the container. (default = true)
propagateEvent Whether or not Glider.js events should bubble (useful for binding events to all carousels). (default = false)
scrollLock If true, Glider.js will scroll to the nearest slide after any scroll interactions. (default = false)
skipTrack Whether or not Glider.js should skip wrapping its children with a 'glider-track' <div>. NOTE: If true, Glider.js will assume that the 'glider-track' element has been added manually. All slides must be children of the track element. (default = false)
scrollLockDelay How long (ms) to wait after scroll event before locking, if too low, it might interrupt normal scrolling. (default = 250)
responsive An object containing custom settings per provided breakpoint. Glider.js breakpoints are mobile-first, be conscious of your ordering. Supported responsive settings are slidesToShow, slidesToScroll, itemWidth, and duration.
containerElement Replace container HTML element.
easing Use any custom easing function, compatible with most easing plugins.

Arrows

If the Glider component should display arrows, you can configure these using the arrows prop.

Selectors

The arrows prop supports an object containing left and right CSS selectors.

arrows={{
  prev: '#buttonPrev',
  next: '#buttonNext',
}}

Note that if you have multiple Glider elements on the same page, you need to assign a different CSS selector to each Glider.

Elements

The arrows prop supports an object containing left and right references to an HTML element.

When using native HTML elements:

arrows={{
  prev: document.getElementById("prev"),
  next: document.getElementById("next")
}}

When using React.useRef:

arrows={{
  prev: leftArrowEl.current,
  next: rightArrowEl.current,
}}

Note that React.useRef will assign a value to current after the component has rendered. This means that on the first render, current is null.

Responsive mode

You can set different settings for different viewport widths.

<Glider
  slidesToShow={1}
  scrollLock
  responsive={[
    {
      breakpoint: 864,
      settings: {
        slidesToShow: 3,
      },
    },
  ]}
>
  {* ... *}
</Glider>

Note that React Glider is designed to be mobile-first, so the order of your breakpoints should be small-to-large.

Container element

If you would like to use a custom element or React component as the parent for your slides, you can use the containerElement property.

function ContainerElement({ children }) {
  return <div className={styles.glider}>{children}</div>;
}

function MyComponent() {
  return <Glider
    slidesToShow={1}
    containerElement={ContainerElement}
  >
    {* ... *}
  </Glider>
}

Events

Event Description
onLoad Called after Glider component is initialized.
onAnimated Called whenever a Glider.js paging animation is complete
onRemove Called whenever a Glider.js animation is complete
onSlideVisible Called whenever a slide a shown. Passed an object containing the slide index
onRefresh Called whenever Glider.js refreshes it's elements or settings
onAdd Called whenever an item is added to Glider.js
onDestroy Called whenever a Glider.js is destroyed
onSlideHidden Called whenever a slide a hidden. Passed an object containing the slide index

Glider Methods

To get access to the current glider instance this react component exposes a ref.

function Example() {
  const gliderRef = React.useRef<GliderMethods>(null);
  return (
    <div>
      <button
        type="button"
        onClick={() => {
          const random = Math.floor(Math.random() * 12);
          gliderRef.current?.scrollItem(random);
        }}
      >
        Scroll to random item
      </button>
      <Glider
        className="glider-container"
        draggable
        hasDots
        slidesToShow={1}
        scrollLock
        ref={gliderRef}
      >
        <div>
          <span>1</span>
        </div>
      </Glider>
    </div>
  );
}

Perspective View

The CSS for the perspective view is not included in Glider.js or this package. You can find it in perspective.css. Please do not file bugs for it as I do not want to support it.

Examples

You may view the examples used in the docs page in the ./examples directory.

FAQs

Can I replace react-slick with react-glider?

If you are interested in migrating from react-slick, please note that react-glider only includes a subset of the features available in react-slick. Most notably, react-glider doesn't include variable width or custom transitions, while autoplay must be handled by you. If you are using react-slick as a carousel to list elements, react-slick probably includes more features than you need. In such cases, replacing it with react-glider would reduce the JavaScript KBs while providing your users with a jank-free experience.

How can I remove the ESLint warning import/no-extraneous-dependencies?

import/no-extraneous-dependencies requires that all dependencies are included in the project's package.json file. Since the CSS file is generated by glider-js, it will not be listed in your package.json file. The preferred option would be to create a local CSS file containing the glider.css file's contents. Alternatively, you may disable the eslint warning for that line. We do not recommend installing glider-js as a dependency in your package as you would then be responsible for maintaining the glider-js and react-glider dependencies in your project.

Can I customize the appearance of the dots/pagination elements?

You may customize the dots by overriding the CSS for .glider-dots and glider-dot.

Alternatively, you may pass a CSS selector to the dots property to assign a DOM element as the container for the Glider's pagination. This allows you to override the CSS for .glider-dots using CSS specificity.

.my-dots-container.glider-dots {
  /* ... */
}

This is also possible when using CSS modules and allows you to have multiple Glider components on the same page, each with different styles.

<div className={styles.banner}>
  <Glider
    dots={`.${style.dots}`}
    slidesToShow={1}
  >
    {* ... *}
  </Glider>
  <div className={style.dots} />
</div>

Can I lazyload images on inactive slides?

The recommended approach for lazy loading images is to use the browser's loading="lazy" implementation. You can use the slide's index to know which images should have the attribute set.

Which browsers are supported?

As react-glider is a wrapper for Glider.js, it should run on all modern browsers. Support for older browsers can be achieved by polyfilling document.classList, window.requestAnimationFrame, Object.assign and CustomEvent.

Developing

yarn
yarn dev

License and Copyright

This software is released under the terms of the MIT license.

react-glider's People

Contributors

adam187 avatar cameronbraid avatar dependabot[bot] avatar dricholm avatar gynekolog avatar hipstersmoothie avatar hotscotch92 avatar jonmumm avatar kevinfarrugia avatar matteopieroni avatar mshaaban0 avatar stanislavvasilyev-sravni avatar vinkodlak avatar zeelmt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-glider's Issues

Uncaught DOMException: Failed to execute 'removeChild' on 'Node'

When navigating from one route to another using a client-side router (ex: react-router), I am receiving a console error

Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.

This usually occurs when the page has a glider and the user navigates away from this page. Then when returning to this page (using back button) it crashes.

Details

  • Version: 3.1.0
  • React: 17.0.2
  • Browser: Chrome v102

useLayoutEffect Warning?

Hi wonderful package thank you for putting this together.

I am getting the following warning message when using the package:

Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used in components that render exclusively on the client. See https://reactjs.org/link/uselayouteffect-ssr for common fixes. at C:\Users\user\project\node_modules\react-glider\dist\index.js:38:26

Not sure how to resolve.

Type definitions for events are incorrect

The type definitions for the events are not correct as there is only a single parameter being passed, the Event. The Context is not in use.

Example:

onSlideVisible?(context: any, event: Event): void;

Should become

onSlideVisible?(event: Event): void;

autoplay support

Hello,

I found react-glider working nicely, but there's no option available for autoplay, where sliders play automatically and also some time interval for autoplay.

Glider is not reinitialized after event handlers are updated

When an event handler is updated, Glider is not reinitialized with the new event handler.

Example

    const [activeSlide, setActiveSlide] = React.useState(1);

    const handleSlideChange = (event: CustomEvent) => {
        console.log(activeSlide); // output: 1

        if (event && event.detail) {
            setActiveSlide({activeSlide: event.detail.slide});
        }
    };

In the example above, we are updating the state variable activeSlide whenever the slide changes, however the value output in the console.log will remain 1, even if the value of activeSlide has changed.

Glider events not firing up

I tried to register to events but none of them are being fired:

  <Glider
    slidesToScroll={5}
    slidesToShow={5}
    draggable={true}
    onRefresh={() => handleOnLoad}
    onLoad={() => handleOnLoad}
    onSlideVisible={() => handleOnLoad}
  >

function handleOnLoad(context: any, event: Event) {
}

from documentation:
/** Called after Glider.js is first initialized /
onLoad?(context: any, event: Event): void;
/
* Called whenever a slide a shown. Passed an object containing the slide index /
onSlideVisible?(context: any, event: Event): void;
/
* Called whenever Glider.js refreshes it's elements or settings */
onRefresh?(context: any, event: Event): void;

Additional Props on responsive settings (hasArrows)

Hi!

It possible to pass "hasArrow" per Responsive Breakpoint?

Example...
I dont need display Arrows on phones but I need display it on tablet... how I can add "hasArrow" prop into component? Only what I see is component allow add only slidesToShow, slidesToScroll (from BreakPoint interface).

I cant use CSS becouse it's more problematic for my case.

Thanks!

How can we get more control over styling the glider-track?

Hi, I am trying to figure out a good way to apply a style on the glider track. For example, how to apply a gap: 12px between the slide items and justify-content: center to align the items to the centre of the screen if there are less number of items than the screen allows; I cannot figure out a non-hacky way of doing this in react.

My current implementation involves giving the slider a unique class and then applying a gap: 12px and justify-content: center on the .glider-track under the unique class.

Support React 17

Overview

Hello! I was curious if React 17 support was on the roadmap to be added to react-glider? It appears this warning is not a direct issue with this package, but some dependencies of this package, specifically @reach/auto-id, which has been updated to signify support for React 17.

Thanks!

Package versions

react-glider version: @latest

`glider-slide-visible` and `glider-slide-hidden` events only fire with `scrollLock`

glider-js exposes two events, glider-slide-visible and glider-slide-hidden which fire when a slide is visible or hidden respectively. On the glider-js package, these fire in all the following three cases:

  • Horizontal scrolling (touch or mouse)
  • Horizontal scrolling (touch or mouse) with scrollLock: true
  • Clicking on the dots

On the react-glider project, the first scenario does not fire any events.
⚠ Horizontal scrolling (touch or mouse)
✅ Horizontal scrolling (touch or mouse) with scrollLock: true
✅ Clicking on the dots

None of the Glider events fire.

 const gliderRef = useRef(null);
<Glider ref={gliderRef} onSlideVisible={(c,e) => console.log(c,e)} onLoad={(c,e) => console.log(c,e)}>
 {children}
</Glider>

Nothing gets logged to the console.

Possible unnecessary required breakpoint settings

For example, if we wish to continue specifying a number for slidesToShow and have itemWidth be auto (undefined), itemWidth may need to be updated to allow for undefined

  breakpoint: number;
  settings: {
    slidesToShow: number | 'auto';
    slidesToScroll: number | 'auto';
    itemWidth: number;
    duration: number;
  };
}```

Allow 'Element' type for arrows

First off, thanks for the library!

Currently, the arrows prop allows object with keys prev and next which both must be string. However, per the Glider.js documentation, element instances can be passed here as well instead of the selectors. See https://nickpiscitelli.github.io/Glider.js/ -> Settings -> arrows

It'd be great if this library took that into account as well

Incomplete documentation

How are you supposed to add options with this wrapper? There is no explanation in the readme, and you can't follow the original documentation because the implementation is not the same.

Cannot navigate to another page with anchor tag

Hi,

I am using react-glider in my project. I put anchor tag in Glider tag.
i.e.
<Glider><a href="https://example.com" target="_blank">Example</a></Glider>
However, I cannot navigate to the web page. Is there any way to achieve page navigation using react-glider for each slide?

Thanks.

onSlideVisible is firing on all slides when unmounting and remounting

When Glider is unmounted and remounted (for example in the case of a popup or modal) then Glider is not initialized correctly and some artefacts from the previous initialization are present. As a result, it fires glider-slide-visible on all pages even if only one slide is visible.

It glides beyond last item if setting "itemWidth" and "exactWidth"

My glider looks like this

<Glider
    slidesToShow={"auto"}
    itemWidth="220"
    exactWidth
    scrollLock
    draggable
>
    <div>....</div>
    <div>....</div>
    <div>....</div>
    <div>....</div>
    <div>....</div>
</Glider>

However when dragging the glider it goes past the last item, see attached image (red border is for the gliders container)

Initial state
image

Over glided state
image

Emotion error

Hi im getting this error from time to time and it seems to be related to glider
everytime the error appears the Glider is gone

im using Nextjs with emotion and mui

image

anyone ran into this problem?
Thank you

Issue with preact and gatsby

When I try to use this package with preact installed on my gatsby website, I run into the following error:

image

The issue only arises when the __importStar helper is used. One way to make that happen is to have an import that mixes default and named imports.

The actual problem is inside the __setModuleDefault helper that __importStar calls.

So I have fixed this issue in a fork here => https://github.com/masoodtalha/react-glider

Thoughts? Should I make a PR out of it?

props.arrows and props.dots are Always Overridden

Based on the code in src/index.tsx, this is how you construct the glider config:

{
      ...this.props,
      arrows: this.props.hasArrows
        ? {
            next: '.glider-next',
            prev: '.glider-prev'
          }
        : undefined,
      dots: this.props.hasDots ? '#dots' : undefined
    }

this means, no matter what I put in the props arrows and dots, it will be overridden, e.g.

<Glider
  arrows={{ prev: '.x-my-left', next: 'x-my-next' }}
  dots="x-my-dots"
>

is this intentional?

Showing `undefined` class on glider-slider on storybook example

This only affects Storybook, however I would like to resolve it to have a better reference for users.

When a user does not specify a className on Storybook, then the slides have undefined as a class.

<div class="glider-slide **undefined** active center visible" data-gslide="0" style="height: auto; width: 1238px;"><h1>1</h1></div>

yarn install error

I forked the repo to work on it, when I run yarn I get this error:

https://github.com/okonet/listr-update-renderer/tarball/upgrade-log-update: Integrity check failed for "listr-update-renderer" (computed integrity doesn't match our records, got "sha1-Bgc/qTFmJ3YHp4FPTh+DlgCBQUw=")

I searched a bit online and this appears to be related to a specific version of a dependency for lint-staged.

Running yarn upgrade lint-staged fixes it!

Would it be worth including your yarn.lock file in the repo?

Thanks!

How to disable arrows based on viewport width change ?

I am trying to disable/enable arrows based on the viewport change. currently, i want to hide arrows on small screens and show arrows on screens having viewport sizes greater than tablets .i have tried using the responsive setting for disabling/enabling the arrows based on breakpoints but it's not working .
my code looks like this

const gliderResponsive = [
 {
   breakpoint: 767,
   settings: {
     slidesToShow: 5,
     hasArrows:false,
     slidesToScroll: 1,
   },
 },
 
];
export default function App() {
 return (
   <div className="App">
     <div className="container">
       <Glider responsive={gliderResponsive} hasArrows={true} slidesToShow={1}  scrollLock hasDots draggable>
         <div className="slide">1</div>
         <div className="slide">2</div>
         <div className="slide">3</div>
         <div className="slide">4</div>
         <div className="slide">5</div>
         <div className="slide">6</div>
         <div className="slide">7</div>
         <div className="slide">8</div>
         <div className="slide">9</div>
         <div className="slide">10</div>
         <div className="slide">11</div>
         <div className="slide">12</div>
       </Glider>
     </div>
    
   </div>
 );
}

codesandbox link

Failed to execute 'removeChild' on 'Node'

The following error occurs when the children of the carousel change:
Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.

I believe this is due to the referenced container being modifier by glider.js:

// in render() of index.tsx

<div className={this.props.className} ref={this.ref}>
      {this.props.children}
</div>
// in glider.js

_.track = document.createElement('div')
_.track.className = 'glider-track'
_.ele.appendChild(_.track)
while (_.ele.children.length !== 1) {
    _.track.appendChild(_.ele.children[0])
}

React expects the element to have the children specified in the render() method, but glider.js has inserted a new <div> element and moved the children into it.

When React attempts to update the children, it is unaware of the change made by glider.js and attempts to remove the children it inserted via the render() method. This fails as the children have been moved.

It seems to me that the only way to resolve this issue would require a change to glider.js -- Add an option that prevents glider.js from adding the glider-track automatically, so that it can be manually added in your render() method.

This would look something like:

// in render() of index.tsx

<div className={this.props.className} ref={this.ref}>
    <div className="glider-track">
         {this.props.children}
    </div>
</div>
// in glider.js

if (_.opt.addTrack) {
    _.track = document.createElement('div')
    _.track.className = 'glider-track'
    _.ele.appendChild(_.track)
    while (_.ele.children.length !== 1) {
        _.track.appendChild(_.ele.children[0])
    }
}
else {
    _.track = _ele.children[0]
}

React 17 - Error: Invalid hook call

Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.



 at resolveDispatcher (/Users/username/Desktop/code/apps/app/app.app/node_modules/react-glider/node_modules/react/cjs/react.development.js:1465:13)
    at Object.useRef (/Users/username/Desktop/code/apps/app/app.app/node_modules/react-glider/node_modules/react/cjs/react.development.js:1504:20)
    at Object.render (/Users/username/Desktop/code/apps/app/app.app/node_modules/react-glider/dist/index.js:38:26)
    at ReactDOMServerRenderer.render (/Users/username/Desktop/code/apps/app/app.app/node_modules/react-dom/cjs/react-dom-server.node.development.js:3872:44)
    at ReactDOMServerRenderer.read (/Users/username/Desktop/code/apps/app/app.app/node_modules/react-dom/cjs/react-dom-server.node.development.js:3690:29)
    at renderToString (/Users/username/Desktop/code/apps/app/app.app/node_modules/react-dom/cjs/react-dom-server.node.development.js:4298:27)
    at Object.renderPage (/Users/username/Desktop/code/apps/app/app.app/node_modules/next/dist/next-server/server/render.js:54:854)
    at Function.getInitialProps (webpack-internal:///./node_modules/next/dist/pages/_document.js:211:19)
    at loadGetInitialProps (/Users/username/Desktop/code/apps/app/app.app/node_modules/next/dist/next-server/lib/utils.js:5:101)
    at renderToHTML (/Users/username/Desktop/code/apps/app/app.app/node_modules/next/dist/next-server/server/render.js:54:1145)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /Users/username/Desktop/code/apps/app/app.app/node_modules/next/dist/next-server/server/next-server.js:112:97
    at async __wrapper (/Users/username/Desktop/code/apps/app/app.app/node_modules/next/dist/lib/coalesced-function.js:1:330)
    at async DevServer.renderToHTMLWithComponents (/Users/username/Desktop/code/apps/app/app.app/node_modules/next/dist/next-server/server/next-server.js:137:387)
    at async DevServer.renderToHTML (/Users/username/Desktop/code/apps/app/app.app/node_modules/next/dist/next-server/server/next-server.js:138:1088)

Export typings

Hi there! It would be cool if user could export typings.

Incomplete type for scrollItem parameter

Hello, first of all thank you for this package!

I have a minor issue with typings in the plugin. scrollItem() expects number as first parameter in the typing as declared in the package:

scrollItem(slideIndex: number, isActuallyDotIndex?: boolean): void;

However the official glider-js documentation states it can have the following arguments: "Arguments: String | Number, Boolean". So having a string as first argument is also valid. If prev is provided it will slide to the previous slide, otherwise to the next slide it seems.
I currently use it with both prev and next with TypeScript ignore comment because of the package typings. The reason for this use case is because it is used in an event listener on arrow key presses.

Can the parameter for scrollItem() be updated to reflect this?

`glider-dots` class is repeated multiple times on the same element

The class name glider-dots is assigned to the same class multiple times instead of one time. This could be replicated in the storybook demo (all examples) by inspecting the HTML of the element with id="dots".

Effects
This does not cause any visible issues but is semantically incorrect and bloats the HTML.

Priority
Low

Workaround
N/A

Is there a way to snap the slides to center when swiped or dragged?

Hi,

I am switching from swiper ~140KiB to this library as it ultra-lightweight and don't expect everything to be here but if there is a way to snap the slides to center when swiped or dragged, that would be great.

Current Behaviour
When swiped or dragged, the slides remain in place where they were left off.
They don't snap back to center.

Current Implementation Code

<Glider className="glider-container" draggable hasDots slidesToShow={1}>

Wanted Behaviour
When swiped or dragged the slides snap to center, just like when you click the arrows or dots.

Thanks

responsive settings ignored

I have this codesandbox
with a simple configuration:

<Glider
  slidesToShow={1.3}
  responsive={[
    {
      breakpoint: 700,
      settings: {
        slidesToShow: 3
      }
    },
    {
      breakpoint: 950,
      settings: {
        slidesToShow: 5
      }
    }
  ]}
>
...
</Glider>

It should show 1.3 slides below 700px, then 3 slides up until 950, and after 5.
It works strange. When you load page at > 950 px, shows 1.3 slides on that breakpoint. Others are ok.
When you load at > 700 that one is broken, bigger is ok.
<500 all are ok. Seems like if it loads non-mobile, responsive breakpoint first it copies default opts to it...

This is what object looks like after init on > 950:
image

I looked a bit through your code and glider-js docs, I think the problem is in

    // When the props update, update the glider
    React.useEffect(() => {
      if (!gliderRef.current) {
        return;
      }

      gliderRef.current.setOption(makeGliderOptions());
      gliderRef.current.refresh(true);
    }, [props]);

setOption(), and that it needs to take 2nd argument as true, to make options global.
Can you check it?

Providing an Arrows prop causes arrows to not render.

Hi there, first of all, thanks for this awesome integration!

I think I've found an issue with the arrows prop, when supplying the prop, the arrows won't render. This is especially problematic when working with different gliders on the same page, since they all need distinct arrow selectors.

I think this is the line that's causing arrows to not render:

https://github.com/hipstersmoothie/react-glider/blob/4cb01307c4422eb55a9ed2dea0ea5d18aa6934c1/src/index.tsx#L286

As a workaround I'm running a useLayoutEffect and adding the arrows manually:

// your arrow selector / elements here

 React.useLayoutEffect(() => {
    if (gliderRef.current && arrows) {
      const { prev: prevArrow, next: nextArrow } = arrows
      const container = gliderRef.current.ele.parentElement
      if (container) {
        container.insertBefore(prevArrow, gliderRef.current.ele)
        container.appendChild(nextArrow)
      }
    }
  }, [arrows])

Let me know if this is expected behaviour or actually a bug. If so, I can attempt a PR that also takes care of #36

Storybook fails on Node 17

Storybook is failing when building using Node 17 and upwards.

Console output:

$ yarn storybook
yarn run v1.22.5
$ start-storybook -p 9001 -c .storybook
info @storybook/react v5.3.21
info 
info => Loading presets
info => Loading presets
info => Loading custom manager config.
info => Loading config/preview file in ".storybook".
info => Loading custom Webpack config (full-control mode).
info => Using base config because react-scripts is not installed.
10% building 1/1 modules 0 active(node:166735) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
(Use `node --trace-deprecation ...` to show where the warning was created)
10% building 1/2 modules 1 active /home/kevin/git/react-glider/node_modules/webpack-hot-middleware/client.js?reload=true&quiet=truenode:internal/crypto/hash:67
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
    at module.exports (/home/kevin/git/react-glider/node_modules/@storybook/core/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/home/kevin/git/react-glider/node_modules/@storybook/core/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/home/kevin/git/react-glider/node_modules/@storybook/core/node_modules/webpack/lib/NormalModule.js:471:10)
    at /home/kevin/git/react-glider/node_modules/@storybook/core/node_modules/webpack/lib/NormalModule.js:503:5
    at /home/kevin/git/react-glider/node_modules/@storybook/core/node_modules/webpack/lib/NormalModule.js:358:12
    at /home/kevin/git/react-glider/node_modules/@storybook/core/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/home/kevin/git/react-glider/node_modules/@storybook/core/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at Array.<anonymous> (/home/kevin/git/react-glider/node_modules/@storybook/core/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
    at Storage.finished (/home/kevin/git/react-glider/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:43:16)
    at /home/kevin/git/react-glider/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:79:9
    at /home/kevin/git/react-glider/node_modules/graceful-fs/graceful-fs.js:90:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v17.2.0

onLoad callback is not firing when glider is initialized

The onLoad callback should fire whenever the Glider component is initialized. This is not happening because the glider-loaded event fires before the onLoad event listener is bound to the element.

This could be resolved by calling the onLoad event manually instead of depending on glider-loaded.

Requirements

  • Should only fire once unless the Glider is destroyed or unmounted.

Autoplay?

Hello

It looks like autoplay isn't a feature in the react component. Is that by design?

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.