Giter VIP home page Giter VIP logo

react-flickity-component's Introduction

React Flickity Component

styled with prettier

Introduction:

A React.js Flickity component.

Install:

# you need to install flickity as peer dependency, please use v2.3.0 for best experience
npm install [email protected]
npm install react-flickity-component

Usage:

V4 Updates

V4 only supports react v18 and above. V4 also comes with an esmodule bundle format to support modern frontend tooling like vite. If you are staying on react v16, please keep using v3.

// Commonjs
const Flickity = require('react-flickity-component');
// Or for ES2015 module
import Flickity from 'react-flickity-component'

const flickityOptions = {
    initialIndex: 2
}

function Carousel() {
  return (
    <Flickity
      className={'carousel'}                
      elementType={'div'}                   
      options={flickityOptions}
      disableImagesLoaded
      reloadOnUpdate
      static
    >
      <img src="/images/placeholder.png"/>
      <img src="/images/placeholder.png"/>
      <img src="/images/placeholder.png"/>
    </Flickity>
  )
}

Example Usage:

See a codesandbox example here: https://codesandbox.io/s/react-flickity-demo-wwszqm

See an example with server side rendering:

https://github.com/theolampert/react-flickity-component-example

And with typescript:

https://github.com/theolampert/react-flickity-component-example/tree/typescript

Props:

Property Type Default Description
className String '' Applied to top level wrapper
elementType String 'div' Wrapper's element type
options Object {} Flickity initialization options
disableImagesLoaded Boolean false Disable call reloadCells images are loaded
flickityRef Function Like ref function, get Flickity instance in parent component
reloadOnUpdate Boolean false Read next section before you set this prop. Run reloadCells and resize on componentDidUpdate
static Boolean false Read next section before you set this prop. Carousel contents are static and not updated at runtime. Useful for smoother server-side rendering however the carousel contents cannot be updated dynamically.

How it works

Under the hood, react-flickity-component uses a React Portal to render children slides inside a Flickity instance. The need for a portal is because after Flickity is initialized, new DOM nodes (mostly Flickity wrapper elements) would be created, this changes the DOM hierarchy of the parent component, thus any future update, whether it's originated from Flickity, like adding/removing slides, or from parent, like a prop changes, will make React fail to reconcile for the DOM snapshot is out of sync.

#64 introduced a new prop to change the underlying render method: instead of using portal, react-flickity-component will directly render children. This is to create a smoother server-side rendering experience, but please be aware using static prop possibly will cause all your future update to fail, which means adding/removing slides will definitely fail to render, so use with caution.

However there is a fail-safe option reloadOnUpdate. It means every time there is a update, we tear down and set up Flickity. This will ensure that Flickity is always rendered correctly, but it's a rather costly operation and it will cause a flicker since DOM nodes are destroyed and recreated. Please also note it means any update, either rerender of the parent, or any of the props change, will always cause an update in the Flickity component. For more information, see a detailed explanation and workaround in #147.

Use Flickity's API and events

You can access the Flickity instance with flickityRef prop just like ref, and use this instance to register events and use API.

// function component
function Carousel () {
  const ref = React.useRef(null);

  function myCustomNext = () {
    // You can use Flickity API
    ref.current.next()
  }

  React.useEffect(() => {
    if (ref.current) {
      ref.current.on("settle", () => {
        console.log(`current index is ${ref.current.selectedIndex}`);
      });
    }
  }, []);

  return (
      <Flickity flickityRef={c => ref.current = c}>
        <img src="/images/placeholder.png"/>
        <img src="/images/placeholder.png"/>
        <img src="/images/placeholder.png"/>
      </Flickity>
      <Button onClick={myCustomNext}>My custom next button</Button>
    )
}
// class component
class Carousel extends React.Component {

  componentDidMount = () => {
    // You can register events in componentDidMount hook
    this.flkty.on('settle', () => {
      console.log(`current index is ${this.flkty.selectedIndex}`)
    })
  }

  myCustomNext = () => {
    // You can use Flickity API
    this.flkty.next()
  }

  render() {
    return (
      <Flickity flickityRef={c => this.flkty = c}>
        <img src="/images/placeholder.png"/>
        <img src="/images/placeholder.png"/>
        <img src="/images/placeholder.png"/>
      </Flickity>
      <Button onClick={myCustomNext}>My custom next button</Button>
    )
  }
}

License Information:

GPLv3

Flickity may be used in commercial projects and applications with the one-time purchase of a commercial license. http://flickity.metafizzy.co/license.html

See this issue for more information

react-flickity-component's People

Contributors

aaronjy avatar ahmadi-akbar avatar antonio-laguna avatar ccope avatar damassi avatar danielmahon avatar gpoole avatar greenkeeper[bot] avatar ivankalinin avatar ixfloma avatar justinemmanuelmercado avatar leo-cheron avatar matthewlein avatar olegrjumin avatar pr1ntr avatar quicksaver avatar shabith avatar snuuson avatar stowns avatar syoung125 avatar theolampert avatar yaodingyd avatar yowainwright 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  avatar  avatar  avatar

react-flickity-component's Issues

How to implement equal cell height hack?

Thanks for creating this component!

I'm trying to implement desandro's equal cell height hack, explained here and shown here.

Here is the hack:

// external js: flickity.pkgd.js

// add this code
Flickity.prototype._createResizeClass = function() {
  this.element.classList.add('flickity-resize');
};

Flickity.createMethods.push('_createResizeClass');

var resize = Flickity.prototype.resize;
Flickity.prototype.resize = function() {
  this.element.classList.remove('flickity-resize');
  resize.call( this );
  this.element.classList.add('flickity-resize');
};

I'm having trouble adapting this code to work with react-flickity-component. My attempt (shown below) is partially working, but causes an issue on first load that makes it seems like there is only one cell (the arrows are disabled and the dots don't appear). This behaviour fixes itself as soon as the carousel moves.

componentDidMount = () => {
    // See: https://codepen.io/desandro/pen/ZXEGVq
    this.flkty.element.classList.add(`flickity-resize`)

    const resize = this.flkty.resize
    this.flkty.resize = () => {
      this.flkty.element.classList.remove(`flickity-resize`)
      resize.call(this)
      this.flkty.element.classList.add(`flickity-resize`)
    }
  }

Can you please show me how to implement desandro's hack with this component?

An in-range update of prettier is breaking the build 🚨

The devDependency prettier was updated from 1.14.2 to 1.14.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for 1.14.3

🔗 Changelog

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Items fixed width not being respected

It all works fine in developer mode. But as soon as we build the project, flickity starts to misbehave. See the capture:

image

So, images overlaps. Sometimes there are blank spaces. In resume, the items fixed width is not being respected.

Any clue about why?

We are using nextJs, btw.

Component not longer dragabble

Since the 3.0.0 version of this component, the component is not longer draggable.

import React from "react";
import { render } from "react-dom";
import Flickity from "react-flickity-component";

const flickityOptions = {
  initialIndex: 7
};

function Carousel() {
  return (
    <Flickity options={flickityOptions}>
      <img src="http://via.placeholder.com/50x150" />
      <img src="http://via.placeholder.com/100x150" />
      <img src="http://via.placeholder.com/150x150" />
      <img src="http://via.placeholder.com/250x150" />
      <img src="http://via.placeholder.com/300x150" />
      <img src="http://via.placeholder.com/350x150" />
      <img src="http://via.placeholder.com/350x150" />
      <img src="http://via.placeholder.com/350x150" />
      <img src="http://via.placeholder.com/350x150" />
    </Flickity>
  );
}
render(<Carousel />, document.getElementById("root"));

See the live example: https://codesandbox.io/s/p7m7w45yl7

Precompile to ES5

Some older browsers and tools do not support ES6. Also it is not currenty supported by create-react-app, which I think will be the main problem for most of us.
Is there a chance to precompile the package before publishing?
Thanks!

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

`render() {
const flickityOptions = {
initialIndex: 0,
autoPlay: 10000,
prevNextButtons: false,
adaptiveHeight: false,
wrapAround: true
}

    return (
        <div className={this.props.cssClasses}>
            {
                this.props.blockData.messages.length ? 
                    <Flickity
                        className={'slide-wrap'} // default ''
                        elementType={'div'} // default 'div'
                        options={flickityOptions} // takes flickity options {}
                        disableImagesLoaded={false} // default false
                        reloadOnUpdate={true} // default false
                        static // default false
                        >
                    
                        {this.props.blockData.messages.map((message, key) =>
                            <div className={"community-message__row " + message.type} key={key}>
                                {message.title ? <p className="community-message__row__title">{message.title}</p> : ""}
                                <img alt={message.title} src={message.image}/>
                                {message.message ? <p className="community-message__row__message">{message.message}</p> : ""}
                            </div>
                        )}
                    </Flickity>
                    :
                    ""
            }
        </div>
    );
}`

I have an app that pulls from an api at an interval, and every once in a while on an app data update, I get this error. I looked at #41 but didn't find any answers there. I'm confused as to how to implement "Run reloadCells and resize on componentDidUpdate" if that is the solution.

Safari - Render carousel dynamically

I'm trying to render this carousel component on Small viewports, and a plain list in other viewports.
I'm using window.matchMedia to render one or the other component

import React, { PureComponent } from "react";
import { render } from "react-dom";
import Flickity from "react-flickity-component";

const flickityOptions = {
  initialIndex: 1,
  pageDots: false
};
const smMedia = window.matchMedia("(max-width: 650px) and (min-width: 0px)");

class Carousel extends PureComponent {
  constructor() {
    super();
    this.state = {
      carousel: false
    };
  }

  componentDidMount() {
    smMedia.addListener(this.onSmall);
    smMedia.addListener(x => console.log("Fired?", x.matches));
  }

  onSmall = ({ matches }) => {
    this.setState({
      carousel: matches ? flickityOptions : false
    });
  };

  render() {
    const { carousel } = this.state;

    if (carousel) {
      return (
        <Flickity options={carousel}>
          <img src="http://via.placeholder.com/50x50" />
          <img src="http://via.placeholder.com/50x50" />
          <img src="http://via.placeholder.com/50x50" />
          <img src="http://via.placeholder.com/50x50" />
          <img src="http://via.placeholder.com/50x50" />
        </Flickity>
      );
    }

    return (
      <div style={{ border: "1px solid", padding: 10 }}>
        Plain List No {this.props.number}
      </div>
    );
  }
}

const Wrapper = () => {
  return (
    <div>
      <Carousel number={1} />
      <Carousel number={2} />
    </div>
  );
};

render(<Wrapper />, document.getElementById("root"));

in Safari only - The second list is not able to change to the carousel, without any errors anywhere.

See this live example: https://codesandbox.io/s/5409mo1qkx

Height not being applied

First and foremost, thanks for your work on this, very much appreciated!

I'm pretty new to react, have used flickity a bunch before, but with this react component I'm not getting proper height on my carousel. If I resize it will recalculate and apply correct height. Not sure if I've configured it wrongly or if it's an issue with the component. Any ideas?

import React from 'react';
import Flickity from 'react-flickity-component';


export default class fullScreenCarousel extends React.Component {

  render() {

    const flickityOptions = {
      imagesLoaded: true,
      wrapAround: true,
      fullscreen: true,
      pageDots: false,
      prevNextButtons: false,
    }

    return (
      <Flickity
        className={'carousel'} // default ''
        elementType={'div'} // default 'div'
        options={flickityOptions} // takes flickity options {}
        disableImagesLoaded={false} // default false
      >
      {this.props.images.map(({ path }, index) => (
        <div key={index} className="carousel-cell">
          <img className="carousel-image" src={path} />
        </div>
      ))}
      </Flickity>
    )
  }
}

imagesloaded needed on updates as well

If you render a carousel, then replace children with new images, imagesloaded is not used, so new carousel will be sized incorrectly

In componentDidUpdate, I added an imagesLoaded to make sure the carousel sizes are recalculated with reloadCells. There are probably some optimizations to not run it on every update, but that's the gist of it. Maybe it should only run on children changes.

https://github.com/theolampert/react-flickity-component/blob/96a209e61e9b8152e17f5756441bd23b9baf2d79/src/index.js#L19-L39

  componentDidUpdate(prevProps, prevState) {
    const {
      children,
      options: { draggable, initialIndex },
      reloadOnUpdate,
    } = this.props;
    const { flickityReady } = this.state;
    if (reloadOnUpdate || (!prevState.flickityReady && flickityReady)) {
      this.flkty.deactivate();
      this.flkty.selectedIndex = initialIndex || 0;
      this.flkty.options.draggable =
        draggable === undefined
          ? children
            ? children.length > 1
            : false
          : draggable;
      this.flkty.activate();
// --- ADDED
      if (!disableImagesLoaded && this.carousel) {
        imagesloaded(this.carousel, () => {
          this.flkty.reloadCells();
        });
      }
// ---
    } else {
      this.flkty.reloadCells();
    }
  }

Re create flickity component

Hi, your implementation of flickity is awesome, but I would like to know how to rebuild the slider after destroying it?
I understand that through flickityRef, but I have not succeeded in instantiating the slider again.

Any idea?

chrome sourcemap warning

This is not a big deal but after i use this component, in chrome i can see this warning

DevTools failed to parse SourceMap: js/index.js.map

and i dont have index.js in my source..
I know i can turn off Enable Javascript source map in chrome setting but..
can fix this?

Flickity initialIndex prop not working

Since the 2.0.0 version of this component, the initialIndex property is not working:

import React from "react";
import { render } from "react-dom";
import Flickity from "react-flickity-component";

const flickityOptions = {
  initialIndex: 7
};

function Carousel() {
  return (
    <Flickity options={flickityOptions}>
      <img src="http://via.placeholder.com/50x150" />
      <img src="http://via.placeholder.com/100x150" />
      <img src="http://via.placeholder.com/150x150" />
      <img src="http://via.placeholder.com/250x150" />
      <img src="http://via.placeholder.com/300x150" />
      <img src="http://via.placeholder.com/350x150" />
      <img src="http://via.placeholder.com/350x150" />
      <img src="http://via.placeholder.com/350x150" />
      <img src="http://via.placeholder.com/350x150" />
    </Flickity>
  );
}
render(<Carousel />, document.getElementById("root"));

See the live example: https://codesandbox.io/s/lljo6rkx2q

flkty.resize is not a function

Hi!

I am using the component inside of a modal, everything is working, arrows and dots are here but all the images are stacked on top of each other. If I resize the window it fixes itself. Following the API on flickity's website, I read that I need to use resize() when I reveal the slider

Function run onClick

function openModal(){
    var carousel = document.querySelector('.carousel');
    var flkty = new Flickity( carousel );
    document.getElementById('modal').style.display = 'flex';
    flkty.resize();
}

Options

const flickityOptions = {
    initialIndex: 0,
    imagesLoaded: true
}

Slider

<Flickity 
  id='test'
  className={'carousel'} // default ''
  elementType={'div'} // default 'div'
  options={flickityOptions} // takes flickity options {}
  disableImagesLoaded={false} // default false
  reloadOnUpdate={true}// default false
>
  {post.frontmatter.images.map(({ publicURL, id }) => (
  <CarouselCell key={id} id={id}>
    <img src={publicURL} alt="" />
  </CarouselCell>
  ))}
</Flickity>

I get flkty.resize is not a function.

I am no JavaScript expert and I am new to React so I apologies in advance if this is a stupid question

Type definition

Hey, appreciate this! Makes it very simple to pull in Flickity.

Are you able to add a type definition to this? Flickity does have one already - not sure if that makes it any easier.

Issues with updating Flickity's options during runtime

Changing Flickity's options during runtime doesn't seem to trigger a rerender. The options are controlled by variables from state, yet updating them doesn't seem to have an effect. Updating props connected to this.state doesn't work. This.forceUpdate() doesn't work either. What worked, though, is making the component appear or disappear by toggling a boolean variable. Is there a better approach that I missed?

https://codesandbox.io/s/j74ry6w38v

flickity carusel no control over margin between images in carusel

opened this issue on stackoverflow:
https://stackoverflow.com/questions/59724659/flickity-carusel-no-control-over-margin-between-images-in-carusel

the problem is i have no control over the the spcae between images in the carusel when resizing the browser window: https://codesandbox.io/s/flickity-changin-margin-example-s5gws

even after adding margin right to each carusel-cel https://codesandbox.io/s/flickity-changin-margin-example-yk0xj the space between two images is inconsistent after resizing the browser window

before resize:
before resize

after resize:
after resize

May not work with an SSR framework

Just a heads-up for anyone who may be trying to use this in a SSR-framework that it may fail.

I was trying to use this component to integrate Flickity in my Gatsby build. While it works when I do a local develop instance, it fails on a local build as well as on my CI.

Gatsby returns:

TypeError: Cannot read property 'path' of undefined

 - build.js:68 buildHTML.catch.err
    [my-project]/[gatsby]/dist/commands/build.js:68:72
 - util.js:16 tryCatcher
    [my-project]/[bluebird]/js/release/util.js:16:23

    etc...

In my case, there's an issue thread over at Gatsby that indicates that an import's SSR-compatibility could likely be the issue: gatsbyjs/gatsby#11464

How to perform an onChange event

I'm trying to get the current index of the slides. So, my first attempt is using something like "onChange". But I see it's not supported in the Props interface:

interface Props {
    className?: string;
    disableImagesLoaded?: boolean;
    elementType?: string;
    flickityRef?: (ref: Flickity) => void;
    options?: FlickityOptions;
    reloadOnUpdate?: boolean;
    static?: boolean;
}

I tried passing the event an an option, with no luck:

const flickityOptions = {
    contain: true,
    pageDots: false,
    cellAlign: 'left',
    onChange: (i) => console.log('index', i)
  }

Any clue?

cellSelector options breaks React on unmounting

Below an example of the bug. Toggle the appearance of Flickity using the button. You should see an error in the sandbox browser window and console.

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

https://codesandbox.io/s/react-flickity-4zu6l

Dependencies:

"flickity": "2.2.1",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-flickity-component": "3.5.0",
"react-scripts": "3.4.1"

I believe the issue is the following:

With the cellSelector option, Flickity changes the DOM outside React. It moves all the non-cell nodes outside of the carousel.

This DOM mutation breaks the reconciliation of React when it tries to unmount a subtree with Flickity in it.

It does not break if the Flickity component has no children or if all of its children match the specified cellSelector. In these cases the above mentioned DOM mutation does not happen.

Suggestions:

  • document this issue in the readme
  • do not pass the cellSelector option to Flickity, effectively disabling this option
  • TypeScript: remove the option entirely or add a warning to the type description

React-Flickity -Component not setting common height across carousels and destroy not working on desktop

I am using React-Flickity component and in mobile it works fine and in desktop it doesn't work and destroy not triggering
And one more isssue is not able to set the maximum height of a cell across all other cells

import React, { Fragment, Component } from "react"
import classNames from "classnames"
import PropTypes from "prop-types"
import Flickity from 'react-flickity-component'

//import GenericCarousal from "../Carousel/Carousel"
import { getCard, getHeading, getRichText } from "../../helpers/uiHelper"
import ProductCarouselCard from "../CardType/ProductCarouselCard"
import AthleteCard from "../CardType/AthleteCard"
import CarouselSetting from "./CarouselSetting"

import "flickity/css/flickity.css";

import cstyles from "../BrandCarousel/Carousel-tw-styles"
import { getImageUrl, getSrcSet } from "../../adapters/cloudinary.adapters"

class Carousel extends Component {
constructor(props) {
super(props)
this.state = {
swiping: false
}
}

flkty = null;
componentDidMount (){
const resize = this.flkty.resize
this.flkty.resize = () => {
this.flkty.element.classList.remove('flickity-resize')
resize.call(this.flkty)
this.flkty.element.classList.add('flickity-resize')
}
}
componentDidUpdate() {
if(this.flkty){
this.flkty.reloadCells()
}
}

componentWillUnmount() {
if (this.flkty) {
  this.flkty.destroy();
}

};
render() {
const { carousel } = this.props
const flickityOptions = {
cellAlign: 'left',
pageDots: false,
selectedAttraction: 0.01,
friction: 0.2,
arrowShape: false,
// watchCSS: true,
//setGallerySize: false,
}
const carouselStyle = carousel.styles && carousel.styles.trim()

    return (
        <Fragment>
            <div
                className={classNames(
                    cstyles[carouselStyle] && cstyles[carouselStyle].heading
                )}
            >
                {carousel.titleCollection &&
                    carousel.titleCollection.items.map(title => {
                        switch (title.__typename) {
                        case "Heading":
                            return getHeading(title)
                        }
                    })}
            </div>
            <div
                className={classNames(
                    cstyles[carouselStyle] &&
                        cstyles[carouselStyle].carouselWrapper
                )}
            >
                    <Flickity className={"slider"} options = { flickityOptions }   flickityRef={c => this.flkty = c}>
                    {carousel &&
                        carousel.carouselPanelsCollection &&
                        carousel.carouselPanelsCollection.items.map(
                            (panel) => { 
                                switch (panel.__typename) {
                                case "Card":
                                    return getCard(panel)
                                case "Product":
                                    return (
                                        <ProductCarouselCard
                                            data={panel}
                                        />
                                    )
                                case "Campaign":
                                    return (
                                        <AthleteCard
                                            data={panel}
                                            classname={carousel.styles}
                                            quotesRequired={
                                                carousel.quotesRequired
                                            }
                                        />
                                    )
                                case "ContentTypeRichText":
                                    return getRichText(panel)
                                }
                            }
                        )}
                </Flickity>
                {carousel.background &&
                carousel.background.__typename == "Image" ? (
                        <img
                            src={getImageUrl(carousel.background.image.url)}
                            alt={carousel.background.altText}
                            title={carousel.background.tooltip}
                        />
                    ) : (
                        carousel.background && (
                            <picture>
                                <source
                                    src={getImageUrl(
                                        carousel.background.desktopImage.url
                                    )}
                                    srcSet={getSrcSet(
                                        carousel.background.desktopImage.url,
                                        768
                                    )}
                                    media='(min-width: 768px)'
                                />
                                <img
                                    src={getImageUrl(
                                        carousel.background.smartphoneImage.url
                                    )}
                                    alt={carousel.background.altText}
                                    title={carousel.background.tooltip}
                                />
                            </picture>
                        )
                    )}
            </div>
        </Fragment>
    )
}

}
Carousel.propTypes = {
carousel: PropTypes.oneOfType([PropTypes.object]).isRequired
}

export default Carousel

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Issue when adding/removing cells from Flickity

I'm trying to add cells dynamically by mapping a state object and remapping after an ajax call ends:

export default class Reviews extends Component {
   constructor(props) {
      super(props);
      this.state = {
         reviewjson: [
            {
               id: 0,
               name: 'Loading...'
            }
         ]
      };
   }
   componentDidMount() {
      getJSON(this.props.dataURL, (err, data) => {
         if (err !== null) {
            alert('error');
            }
         } else {
            this.setState({reviewjson: data.reviews});
         }
      });
   }
   componentDidUpdate() {
      console.log('foi');
   }
   render() {
      const flickityOptions = {
         cellSelector: '.review',
      }
      return (
         <div className="carousel-holder">
            <Flickity options={flickityOptions} reloadOnUpdate >
               {this.state.reviewjson.map(i => (
                  <Cell className="review" key={i.id} name={i.name} />
               ))}
            </Flickity>
         </div>
      )
   }
}

However, what I get rendered after the ajax call is something like this:

<div class="flickity-enabled is-draggable" tabindex="0">
   <div class="flickity-viewport" style="height: 175px; touch-action: pan-y;">
      <div class="flickity-slider" style="left: 0px; transform: translateX(27.43%);">
         <Cell class="review">...</Cell>
      </div>
   </div>
   <Cell class="review">...</Cell>
   <Cell class="review">...</Cell>
   <Cell class="review">...</Cell>
   <Cell class="review">...</Cell>
   <Cell class="review">...</Cell>
</div>

I mean, if I have more cells in the remap than I had before, they're added outside the viewport and the slider. And if I have less cells in the ajax call than I had before, I got an error:

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

Is it a bug or am I doing something wrong?

Fullscreen not working

This might not be related to this library, but as the flickity-fullscreen package hasn't been updated for a year, just decided to post here.

We are using flickity in one of our projects, and added the package for fullscreen flickity-fullscreen, it had been working for a while, but like a month ago it suddenly stopped working, and when we call
this.flkty.toggleFullscreen();

it returns:
TypeError: _this2.flkty.toggleFullscreen is not a function

As I said, it worked before, and we never changed our code

this.flkty.previous(); or this.flkty.next(); still work smoothly.

Any clues?

Cannot read property 'innerWidth' of undefined

We're consistently getting this error in our isomorphic app. Not sure if this is something you've seen but flagging anyways for future weary Googlers. Will update if I find a solution.

image

RTL support

Hi,
thanks for this good library.
I need RTL support. Does it support ?

Wrong type definition of flickityRef

In index.d.ts type of flickityRef is HTMLDivElement. It is wrong. It makes troubles on binding events or something else, using refference.

<Flickity flickityRef={ref => (this.flkty = ref)} />
...
this.flkty.on("select", () => {
  console.log(`current index is ${this.flkty.selectedIndex}`);
});

Property 'on' does not exist on type 'HTMLDivElement'.

Update dependencies [email protected] -> [email protected]

npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.

as you can see, fbjs 1.0.0 (Sep 18, 2018) related to core-js 2, but fbjs v2.0.0 (Sep 23, 2019) released. maybe it's time to update the dependencies?

An in-range update of react is breaking the build 🚨

There have been updates to the react monorepoundefined

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the react group definition.

react is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v16.5.1

16.5.1 (September 13, 2018)

React

  • Improve the warning when React.forwardRef receives an unexpected number of arguments. (@andresroberto in #13636)

React DOM

  • Fix a regression in unstable exports used by React Native Web. (@aweary in #13598)
  • Fix a crash when component defines a method called isReactComponent. (@gaearon in #13608)
  • Fix a crash in development mode in IE9 when printing a warning. (@link-alex in #13620)
  • Provide a better error message when running react-dom/profiling with schedule/tracking. (@bvaughn in #13605)
  • If a ForwardRef component defines a displayName, use it in warnings. (@probablyup in #13615)

Schedule (Experimental)

  • Add a separate profiling entry point at schedule/tracking-profiling. (@bvaughn in #13605)
FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Component breaks SSR

When trying to render this on the server I get -

ReferenceError: window is not defined
  at Object.<anonymous> (/home/nodejs/app/node_modules/flickity/js/index.js:39:5)

Unexpected token: name (src_FlickityComponent)

Thanks for the react flickity component. I am getting below error when I try to build with npm run build command.

ERROR in 0.87a941d054f3f7a31f25.chunk.js from UglifyJs
Unexpected token: name (src_FlickityComponent) [0.87a941d054f3f7a31f25.chunk.js:1079,6]
Child html-webpack-plugin for "index.html":
1 asset

build script I am using is : cross-env NODE_ENV=production webpack --config internals/webpack/webpack.prod.babel.js --color -p --progress --hide-modules --display-optimization-bailout

If I remove -p option then build is successful. Is react flickity component supported by wedpack module? . I am using react boilerplate module to develop my application. Please advice?

Failed to execute 'removeChild' on 'Node'

Hi, I just setup a PoC using this library and all went OK following the setup guide, the carousel works perfectly and the implementation was really easy.

I''m however getting an error when transitioning back-and-forth between the view where the carousel lives and other ones:

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

I am using a mix of angularJS + uiRouter and React right now, but I'm not sure it has to do with the stack itself. I wonder if I need to make something happen on componentWillUnmount to make sure all references to DOM elements used by flickity are purged (flickity.destroy()?).

From the stack trace the error seems to stem from FlickityComponent.

screen shot 2018-07-19 at 3 35 31 pm

state update on an unmounted component

The usual

Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.

Strack trace

warningWithoutStack	@	react-dom.development.js:506
warnAboutUpdateOnUnmounted	@	react-dom.development.js:18271
scheduleWork	@	react-dom.development.js:19681
enqueueSetState	@	react-dom.development.js:11141
Component.setState	@	react.development.js:335
setFlickityToReady	@	index.js:95
proto.emitEvent	@	ev-emitter.js:99
ImagesLoaded.complete	@	imagesloaded.js:249
ImagesLoaded.check	@	imagesloaded.js:210
setTimeout (async)		
ImagesLoaded	@	imagesloaded.js:117
ImagesLoaded	@	imagesloaded.js:83
componentDidMount	@	index.js:100
commitLifeCycles	@	react-dom.development.js:17130
commitAllLifeCycles	@	react-dom.development.js:18532
callCallback	@	react-dom.development.js:149
invokeGuardedCallbackDev	@	react-dom.development.js:199
invokeGuardedCallback	@	react-dom.development.js:256
commitRoot	@	react-dom.development.js:18744

setFlickityToReady needs to make sure component is still mounted

An in-range update of babel-plugin-add-module-exports is breaking the build 🚨

Version 0.3.3 of babel-plugin-add-module-exports was just published.

Branch Build failing 🚨
Dependency babel-plugin-add-module-exports
Current Version 0.3.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

babel-plugin-add-module-exports is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes v0.3.3

Bug Fixes

Commits

The new version differs by 5 commits.

  • d76d035 chore: tweaks CI/deploy enviroiment
  • ab74696 0.3.3
  • db82c3f fix: closes #60, #63
  • 8e83ff9 test: Add issues #60, #63 reproducing test
  • c37b6f1 docs: add See also section [ci skip]

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Licensing issues

Hi,

from what I see you're packaging whole Flickity with the wrapper and according to their license this falls under Commercial OEM License. You should probably define Flickity as a peer dependency and require users to attach it to the window object until Flickity team fixes the issue with requiring the library.

Focus flickity on mount

Wonder if you could help me out with something - I need to focus flickity on mount (so keyboard nav can be use right away) as per https://codepen.io/desandro/pen/JoemRR but I'm struggling.

const flickity = useRef(null);

useEffect(() => {
    if (flickity.current) flickity.current.element.focus();
  }, [flickity.current]);

<Flickity
    className="EntryHeroSlideshow__cells"
    options={flickityOptions}
    flickityRef={c => (flickity.current = c)}
    static
>
    [...]
</Flickity>

On page load, document.activeElement is the body element.

Any ideas where I'm going wrong?

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.