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

react-dynamic-swiper

v2.0.2

Published

React wrapper for IDangerous Swiper that auto-magically updates slides, and reinitializes.

Downloads

1,504

Readme

react-dynamic-swiper

Travis

React wrapper for iDangerous-Swiper that auto-magically reinitializes and updates when configuration changes.

Demo

Installation

$ npm i --save react-dynamic-swiper

Usage

// Basic Usage
function MySwiper() {
  return (
    <Swiper
      swiperOptions={{
        slidesPerView: 42
      }}
      navigation={false}
      pagination={false}
    >
      <Slide onActive={swiper => console.log('Slide Active!')} />
    </Swiper>
  )
}

// Advanced Usage
//
// Swiper will automatically update swiper instance when children change (i.e. Slides),
// and/or re-initialize if swiper options change. Also, event handlers
// (`onTouchMove`, `onSlideChangeEnd`, etc.) are delegated. Changing them will
// require no reinitialization, while still functioning as expected.
import React, { Component } from 'react'
import { Swiper, Slide } from 'react-dynamic-swiper'
import 'react-dynamic-swiper/lib/styles.css'

class MySwiper extends Component {
  constructor(props, context) {
    super(props, context)
    this.state = {
      slides: []
    }
  }

  componentWillMount() {
    getAsyncSlideData().then(slides => this.setState({ slides }))
  }

  render() {
    const { slides } = this.state

    return (
      <Swiper
        swiperOptions={{
          slidesPerView: 'auto'
        }}
        nextButton={<MyNextButton />}
        prevButton={swiper => (
          <MyPrevButton onClick={() => swiper.slideNext()} />
        )}
        onTouchMove={(swiper, event) => doSomething()}
      >
        {slides.map(slide => (
          <Slide {...slide} />
        ))}
      </Swiper>
    )
  }
}

API

Swiper

Props

  • swiperOptions (Object) Options passed to swiper instance.
  • wrapperClassName (String) Classname for underlying wrapper element.
  • navigation (Boolean) Display navigation elements (true)
  • nextButton (Element|Function) Navigation next element (<div className="swiper-button-next" />)
  • prevButton (Element|Function) Navigation previous element (<div className="swiper-button-prev" />)
  • pagination (Boolean|Element|Function) Pagination is active by default, use false to hide. (<div className="swiper-pagination" />)
  • paginationClickable (Boolean) Enable clickable pagination.
  • scrollBar (Boolean|Element|Function) Scrollbar is hidden by default, use false to show.
  • onInitSwiper (Function) Function invoked every time swiper instance is initialized, invoked will swiper as first argument.
  • All event handlers are supported as well (i.e. onTouchMove, etc.)

note: The following props can be functions: nextButton, prevButton, pagination, and scrollBar. If functions, they will be invoked with the underlying Swiper instance as the one and only argument. They must return a renderable element.

Methods

  • swiper() Returns underlying swiper instance.

Slide

Props

  • onActive (Function) Invoked with swiper instance when Slide is active. Not invoked on initialization.