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

rc-lightbox

v2.1.9

Published

This is an excellent lightbox. It is modeled on the jQuery version of the lightbox2. It has a great user experience

Downloads

22

Readme

This is an excellent lightbox. It is modeled on the jQuery version of the lightbox2. It has a great user experience. :100:

安装 :rocket:

npm install rc-lightbox --save

or https://github.com/leesx/rc-lightbox.git

如果你clone下来的,请在项目中使用babel,转化代码为es5

tips: 如果你的项目中没有安装 rc-tween-one 需要安装一下。

用法

import Lightbox from 'rc-lightbox'

<Lightbox
        imgSource={this.state.lightboxImgData}
        isOpen={this.state.lightboxIsOpen}
        currentImage = {this.state.currentImage}
        onClose={this.closeLightBox}
/>

参数说明 :art:

属性|类型|默认值|说明 -|-|-|- isOpen|布尔值{Boolean}|false|设置lightbox的状态 imgSource|数组{Array}|[]| [{src:'http://'}] currentImage|布尔值{Number}|0 | 当前第几张图片 onClose|函数{Function}|-|关闭lightbox

示例代码 :tada:

import React, { Component, PropTypes } from 'react'
import { findDOMNode } from 'react-dom'
import Lightbox from 'rc-lightbox'


const MockData = [{
    src:'./src/images/01.jpg',
    title:'图片1',
},{
    src:'./src/images/02.jpg',
    title:'图片2',
},{
  src:'https://gss0.bdstatic.com/5eR1dDebRNRTm2_p8IuM_a/res/r/image/2016-09-02/9577e9be05aea818907880ac66bdf4a0.jpg'
},{
  src:'https://gss0.bdstatic.com/5eR1dDebRNRTm2_p8IuM_a/res/r/image/2016-09-02/177e848bf4f0df538576f5422029c3e6.jpg'
}]

const MockData2 = [{
    src:'http://www.people.com.cn/NMediaFile/2016/0902/MAIN201609021911314859050338728.jpg',
    title:'图片1',
},{
    src:'http://www.people.com.cn/NMediaFile/2016/0902/MAIN201609021348521914980960649.jpg',
    title:'图片2',
},{
  src:'https://gss0.bdstatic.com/5eR1dDebRNRTm2_p8IuM_a/res/r/image/2016-09-02/9577e9be05aea818907880ac66bdf4a0.jpg'
},{
  src:'https://gss0.bdstatic.com/5eR1dDebRNRTm2_p8IuM_a/res/r/image/2016-09-02/177e848bf4f0df538576f5422029c3e6.jpg'
},{
  src:'http://www.wallcoo.com/animal/v195_Lively_Dogs/wallpapers/1280x800/Lively_Dogs_wallpaper_MIX88041_wallcoo.com.jpg'
},{
  src:'http://www.wallcoo.com/animal/v195_Lively_Dogs/wallpapers/1280x800/Lively_Dogs_wallpaper_MIX88041_wallcoo.com2.jpg'
}]



export default  class Lightbox2 extends Component{

    constructor(props, context) {
        super(props, context)
        this.state = {
            lightboxImgData:[],
            lightboxIsOpen:false,
            currentImage:0,
        }
    }

    componentDidMount = ()=>{

        //findDOMNode().appendChild('<div></div>')
        //document.body.appendChild(findDOMNode(this.refs.mask))
    }

    closeLightBox=()=>{
      this.setState({
        lightboxIsOpen:false
      })
    }

    showPicModal(imgGrounp){
        this.setState({
            lightboxIsOpen:true,
            currentImage:imgGrounp.index || 0,
            lightboxImgData:imgGrounp.imgs,
        })
    }

    renderImgList = (data)=>{
        return (
            data.map((item,index)=>{
                return (
                  <li
                   key={`img_${index}`}
                   onClick={this.showPicModal.bind(this,{imgs:data,index})}
                   >
                    <img src={item.src} />
                  </li>
                )
            })
        )
    }

    render() {
        return (
            <div className="self-calendar">
                <button
                  onMouseDown={this.handleMouseDown}
                  onTouchStart={this.handleTouchStart}>
                  Toggle
                </button>
                <ul className="img-list clearfix">
                    { this.renderImgList(MockData) }
                </ul>
                <h2>第二组图片</h2>
                <ul className="img-list clearfix">
                    { this.renderImgList(MockData) }
                </ul>
                <h2>第三组图片</h2>
                <ul className="img-list clearfix">
                    { this.renderImgList(MockData2) }
                </ul>

                {
                  this.state.lightboxImgData.length?
                  <Lightbox
                    imgSource={this.state.lightboxImgData}
                    isOpen={this.state.lightboxIsOpen}
                    currentImage = {this.state.currentImage}
                    onClose={this.closeLightBox}
                  /> : null
                }


            </div>
        );
    }
}

DEMO

演示demo