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-mapper

v0.1.11

Published

React Native component to allow clickable areas on an image

Downloads

749

Readme

react-native-image-mapper

React Native component to allow clickable areas on an image

Setup

$ yarn add react-native-image-mapper --save

Usage

Import the ImageMapper component from react-native-image-mapper and use it as seen below:

import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Image Mapper } from 'react-native-image-mapper';

const imageSource = require('./path/to/my/image.jpg');
const MAPPING = [
  {
    id: '0',
    name: 'First Area Name',
    shape: 'rectangle',
    width: 30,
    height: 40,
    x1: 80,
    y1: 500,
    prefill: 'red',
    fill: 'blue'
  },
  {
    id: '1',
    name: 'Second Area Name',
    shape: 'rectangle',
    x2: 155,
    y2: 540,
    x1: 125,
    y1: 500
  },
]

class MyReactNativeComponent extends Component {
  // ....
  render() {
    return (
      <ImageMapper
        imgHeight={500}
        imgWidth={250}
        imgSource={imageSource}
        imgMap={MAPPING}
        onPress={(item, idx, event) => this.onAnyAreaPress(item, idx, event)}
        containerStyle={styles.myCustomStyle}
        selectedAreaId="my_area_id"
      />
    );
  }
}

Properties

|Prop Name|Type|Description|Example| |---|---|---|---| |imgSource|string|Image source url| required| |imgMap|array|Mapping for image| See below | |selectedAreaId|string or array|ID of the currently selected area or array of ids| 'areaOne' or ['areaOne', 'areaTwo']| |imgWidth|number|Image width|Displayed width| |imgHeight|number|Image height|Displayed height| |multiselect|boolean| Defaults to false. Allows for tracking of multiple selections.|true or false|

When multiselect is set to true, selectedAreaId must be an array of ids rather than a string

|Props callbacks|Called on|Signature| |---|---|---| |onPress|Click on an area in image|(item: object, index: number, event: object)|

imgMap is an object describing touchable areas in the image.

|Property|Type|Description| |---|:---:|---| |id|string|ID of the item used for selected or not selected| |name|string|Name of the item| |shape|string|Required - Either rectangle or circle| |prefill|string|rgba(255, 255, 255, 0.5)| |fill|string|rgba(255, 255, 255, 0.5)| |x1|number|Required - Top Left X coordinate in rectangle or Center X coordinate in circle| |y1|number|Required - Top Left Y coordinate in rectangle or Center Y coordinate in circle| |x2|number|Required for Rectangle unless width (below) is specified - Bottom Left X coordinate in rectangle| |y2|number|Required for Rectangle unless height (below) is specified - Bottom Left Y coordinate in rectangle| |width|number|Required for Rectangle unless x2 (above) is specified - Width of rectangle| |height|number|Required for Rectangle unless y2 (above) is specified - Height of rectangle| |radius|number|Required for Circle - Radius of circle|

Thanks

Big thanks to Coldiary and his React project

License

Copyright (c) 2019 Marc Salo MIT License See LICENSE for specifics