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-native-image-drag

v1.0.0

Published

这是一个为了自由拖动图片而开发的库。

Downloads

4

Readme

react-native-image-drag

这是一个为了自由拖动图片而开发的库。

示例

ImageContainer介绍

这个组件默认展示一个九宫格的图片框,图片可以在这个框内自由的拖动,根据拖动的结果自动排序图片。

这个组件非常适合类似于编辑发布一批图片的场景。

用户最多上传9张图片,可以自由的排序以及添加删除。

使用

使用某个上传组件获取到要上传的图片列表。通过props传递给组件

 <ImageContainer ref="container"
    renderItem={this.renderItem.bind(this)}
    moveEnd={this.moveEnd.bind(this)}
    images={this.state.images} >
    <Text style={{ color: "#fff", margin: 10 }}>自定义加入的文字或者组件</Text>
</ImageContainer>

renderItem(item, index) {
    return <Image source={{ uri: item.uri }} style={{ width: 100, height: 100 }} />
}

如果想要知道最终的结果,可以使用this.refs.container.getImages()方法拿到当前的排序结果。

props介绍

static defaultProps = {
    images: [],     //传入的图片列表,这里假设使用组件上传,图片地址使用uri字段
    style: null,    //外部容器的样式,如果没有特殊需求会自动宽,没有高。
    renderItem: function (item, index) { }, //自定义渲染单个项目,参数包括传入个单个数据、角标
    moveStart: function (index) { },        //开始移动之前的钩子,可以设定样式、禁止ScrollView等
    moveEnd: function (old_index, new_index, e) { },    //移动结束,参数:原角标,将要插入的角标,已经移动的x/y
}

ImageMove介绍

这个组件是为了拖拽图片而开发的。

内部根据手势移动图片,只要外部容器允许,图片就可以任意拖动。

使用

可以自定义要拖动的内容的样式和具体内容。

<ImageMove
    moveEnd={e => this.moveEnd(index, e)}
    moveStart={() => this.props.moveStart(index)}
    renderItem={() => this.props.renderItem(item, index)} />

props介绍

static defaultProps = {
    renderItem: function () { },    //渲染自定义内容
    moveStart: function () { },     //拖动开始的事件
    moveEnd: function () { },       //拖动结束的事件
}

实际的使用可以参考test文件夹下的demo文件 使用react-native-syan-image-picker组件上传图片 使用Button组件显示按钮,触发事件