Full Code of sahlhoff/react-native-pulse for AI

master 3446363ff20e cached
5 files
8.0 KB
1.9k tokens
5 symbols
1 requests
Download .txt
Repository: sahlhoff/react-native-pulse
Branch: master
Commit: 3446363ff20e
Files: 5
Total size: 8.0 KB

Directory structure:
gitextract_gt1y39o7/

├── .gitignore
├── LICENSE
├── README.md
├── package.json
└── pulse.js

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
.DS_Store

================================================
FILE: LICENSE
================================================
MIT License

Copyright (c) 2017 Chad Sahlhoff

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: README.md
================================================
# React Native Pulse Animation

![react native pulse](https://raw.githubusercontent.com/sahlhoff/react-native-pulse/master/pulse-gif.gif)

## Installation

```
  npm install react-native-pulse --save
```

## Usage

```js
const Pulse = require('react-native-pulse').default;

class helloWorld extends Component {
  render() {
    return (
      <View style={styles.container}>
        <Pulse color='orange' numPulses={3} diameter={400} speed={20} duration={2000} />
      </View>
    );
  }  
}

```

## Props

Component accepts several self-descriptive properties:


- **`color`** _(String)_ - Backgroundcolor for pulse. React-native colors supported. Default color is blue.
- **`diameter`** _(Number)_ - This is the maximum diameter that a pulse will be. Defaults to 400.
- **`duration`** _(Number)_ - Duration in milliseconds this is the delay new pulses will be created. Defaults to 1000.
- **`image`** _(Object)_ - Image for center pulse thumbnail.
- **`initialDiameter`** _(Number)_ - The diameter new pulses will start with. Defaults to 0.
- **`numPulses`** _(Number)_ - This is the number of pulses that will be rendered. Defaults to 3.
- **`pulseStyle`** _(Object)_ - Style properties for pulses (borderColor eg.)
- **`speed`** _(Number)_ - Speed in milliseconds pulse will redraw. Defaults to 10.
- **`style`** _(Object)_ - Style properties for pulse container (positioning eg.)


================================================
FILE: package.json
================================================
{
  "name": "react-native-pulse",
  "version": "1.0.7",
  "description": "React Native Pulse Animation",
  "main": "pulse.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/sahlhoff/react-native-pulse.git"
  },
  "keywords": [
    "react",
    "react-component",
    "ios",
    "react-native",
    "animation",
    "ui",
    "pulse"
  ],
  "author": "Chad Sahlhoff",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/sahlhoff/react-native-pulse/issues"
  },
  "homepage": "https://github.com/sahlhoff/react-native-pulse#readme"
}


================================================
FILE: pulse.js
================================================
import React, {
  Component
} from 'react';
import PropTypes from 'prop-types';
import {
  View,
  Text,
  Image,
  StyleSheet,
} from 'react-native';

const styles = StyleSheet.create({
    container: {
        position: 'absolute',
        left: 0,
        right: 0,
        alignItems: 'center'
    },
    pulse: {
        position: 'absolute',
        flex: 1
    }
});

export default class Pulse extends Component {
    static propTypes = {
        color: PropTypes.string,
        diameter: PropTypes.number,
        duration: PropTypes.number,
        image: PropTypes.object,
        initialDiameter: PropTypes.number,
        numPulses: PropTypes.number,
        pulseStyle: PropTypes.object,
        speed: PropTypes.number,
        style: PropTypes.object
    };

    static defaultProps = {
        color: 'blue',
        diameter: 400,
        duration: 1000,
        image: null,
        initialDiameter: 0,
        numPulses: 3,
        pulseStyle: {},
        speed: 10,
        style: {
            top: 0,
            bottom: 0,
            flexDirection: 'row',
            justifyContent: 'center',
            alignItems: 'center'
        }
    }

    constructor(props){
        super(props);

        this.state = {
            color: this.props.color,
            duration: this.props.duration,
            image: this.props.image,
            maxDiameter: this.props.diameter,
            numPulses: this.props.numPulses,
            pulses: [],
            pulseStyle: this.props.pulseStyle,
            speed: this.props.speed,
            started: false,
            style: this.props.style
        };
    }

    mounted = true;

    componentDidMount(){
        const {numPulses, duration, speed} = this.state;

        this.setState({started: true});

        let a = 0;
        while(a < numPulses){
            this.createPulseTimer = setTimeout(()=>{
                this.createPulse(a);
            }, a * duration);

            a++;
        }

        this.timer = setInterval(() => {
            this.updatePulse();
        }, speed);
    }

    componentWillUnmount(){
        this.mounted = false;
        clearTimeout(this.createPulseTimer);
        clearInterval(this.timer);
    }

    createPulse = (pKey) => {
        if (this.mounted) {
            let pulses = this.state.pulses;

            let pulse = {
                pulseKey: pulses.length + 1,
                diameter: this.props.initialDiameter,
                opacity: .5,
                centerOffset: ( this.state.maxDiameter - this.props.initialDiameter ) / 2
            };

            pulses.push(pulse);

            this.setState({pulses});
        }
    }

    updatePulse = () => {
        if (this.mounted) {
            const pulses = this.state.pulses.map((p, i) => {
                let maxDiameter = this.state.maxDiameter;
                let newDiameter = (p.diameter > maxDiameter ? 0 : p.diameter + 2);
                let centerOffset = ( maxDiameter - newDiameter ) / 2;
                let opacity = Math.abs( ( newDiameter / this.state.maxDiameter ) - 1 );

                let pulse = {
                    pulseKey: i + 1,
                    diameter: newDiameter,
                    opacity: (opacity > .5 ? .5 : opacity),
                    centerOffset: centerOffset
                };

                return pulse;

            });

            this.setState({pulses});
        }
    }

    render(){
        const {color, image, maxDiameter, pulses, pulseStyle, started, style} = this.state;
        const containerStyle = [styles.container, style];
        const pulseWrapperStyle = {width: maxDiameter, height: maxDiameter};

        return (
            <View style={containerStyle}>
                {started &&
                    <View style={pulseWrapperStyle}>
                        {pulses.map((pulse) =>
                            <View
                                key={pulse.pulseKey}
                                style={[
                                    styles.pulse,
                                    {
                                        backgroundColor: color,
                                        width: pulse.diameter,
                                        height: pulse.diameter,
                                        opacity: pulse.opacity,
                                        borderRadius: pulse.diameter / 2,
                                        top: pulse.centerOffset,
                                        left: pulse.centerOffset
                                    },
                                    pulseStyle
                                ]}
                            />
                        )}
                        {image &&
                            <Image
                                style={image.style}
                                source={image.source}
                            />
                        }
                    </View>
                }
            </View>
        )
    }
}
Download .txt
gitextract_gt1y39o7/

├── .gitignore
├── LICENSE
├── README.md
├── package.json
└── pulse.js
Download .txt
SYMBOL INDEX (5 symbols across 1 files)

FILE: pulse.js
  class Pulse (line 25) | class Pulse extends Component {
    method constructor (line 56) | constructor(props){
    method componentDidMount (line 75) | componentDidMount(){
    method componentWillUnmount (line 94) | componentWillUnmount(){
    method render (line 140) | render(){
Condensed preview — 5 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (9K chars).
[
  {
    "path": ".gitignore",
    "chars": 9,
    "preview": ".DS_Store"
  },
  {
    "path": "LICENSE",
    "chars": 1070,
    "preview": "MIT License\n\nCopyright (c) 2017 Chad Sahlhoff\n\nPermission is hereby granted, free of charge, to any person obtaining a c"
  },
  {
    "path": "README.md",
    "chars": 1388,
    "preview": "# React Native Pulse Animation\n\n![react native pulse](https://raw.githubusercontent.com/sahlhoff/react-native-pulse/mast"
  },
  {
    "path": "package.json",
    "chars": 647,
    "preview": "{\n  \"name\": \"react-native-pulse\",\n  \"version\": \"1.0.7\",\n  \"description\": \"React Native Pulse Animation\",\n  \"main\": \"puls"
  },
  {
    "path": "pulse.js",
    "chars": 5028,
    "preview": "import React, {\n  Component\n} from 'react';\nimport PropTypes from 'prop-types';\nimport {\n  View,\n  Text,\n  Image,\n  Styl"
  }
]

About this extraction

This page contains the full source code of the sahlhoff/react-native-pulse GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 5 files (8.0 KB), approximately 1.9k tokens, and a symbol index with 5 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!