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-sticky-range-slider

v0.1.6

Published

[React Native | TypeScript] A pure TypeScript component offering a customizable range slider optimized for performance. It supports dragging functionalities for selecting a range of values, with values that smoothly follow the thumb. This component is ful

Downloads

455

Readme

React Native Sticky Range Slider 🌟

A pure TS component offering a customizable range slider optimized for performance. It supports dragging functionalities for selecting a range of values, with values that smoothly follow the thumb. This component is fully compatible with both Android and iOS platforms. Primarily forked from rn-range-slider.

Features ✨

  • Optimized Performance: Designed to ensure smooth and responsive interactions even with complex UI components.
  • Full Customization: Highly customizable to fit your application's specific requirements.
  • Cross-Platform Compatibility: Works seamlessly on both Android and iOS platforms.
  • Responsive: Provides a responsive user experience, adapting to various screen sizes and orientations.
  • Programmatic Control: Offers methods to programmatically control the slider behavior.

Preview 🦋

Installation 📦

npm install react-native-sticky-range-slider
yarn add react-native-sticky-range-slider

Usage 🚀

import React, { useCallback, useState } from "react";
import { Button, StyleSheet, Text, View } from "react-native";
import RangeSlider from "react-native-sticky-range-slider";

const MIN_AGE = 18;
const MAX_AGE = 60;

const Thumb = (type: "high" | "low") => (
  <View
    style={[styles.thumb, { backgroundColor: type === "high" ? "lime" : "purple" }]}
  />
);
const Rail = () => <View style={styles.rail} />;
const RailSelected = () => <View style={styles.railSelected} />;

const App = () => {
  const [min, setMin] = useState(MIN_AGE);
  const [max, setMax] = useState(MAX_AGE);
  const [disableRange, setDisableRange] = useState(false);

  const handleValueChange = useCallback((newLow: number, newHigh: number) => {
    setMin(newLow);
    setMax(newHigh);
  }, []);

  const handleToggle = () => {
    setDisableRange((prev) => !prev);
  };

  return (
    <View style={styles.container}>
      <Text style={styles.title}>{disableRange ? "Set your age" : "Set Age Range"}</Text>
      <RangeSlider
        style={styles.slider}
        min={MIN_AGE}
        max={MAX_AGE}
        step={1}
        minRange={5}
        low={min}
        high={max}
        onValueChanged={handleValueChange}
        renderLowValue={(value) => <Text style={styles.valueText}>{value}</Text>}
        renderHighValue={(value) => (
          <Text style={styles.valueText}>{value === MAX_AGE ? `+${value}` : value}</Text>
        )}
        renderThumb={Thumb}
        renderRail={Rail}
        renderRailSelected={RailSelected}
        disableRange={disableRange}
      />
      <Button
        onPress={handleToggle}
        title={disableRange ? "Switch to double control" : "Switch to single control"}
      />
    </View>
  );
};

const THUMB_RADIUS = 10;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: "center",
    padding: 20,
  },
  title: {
    fontSize: 24,
    textAlign: "center",
    marginBottom: 20,
  },
  slider: {
    marginVertical: 20,
  },
  valueText: {
    color: "black",
  },
  thumb: {
    width: THUMB_RADIUS * 2,
    height: THUMB_RADIUS * 2,
    borderRadius: THUMB_RADIUS,
    borderWidth: 3,
    borderColor: "black",
    backgroundColor: "red",
  },
  rail: {
    flex: 1,
    height: 3,
    borderRadius: 3,
    backgroundColor: "grey",
  },
  railSelected: {
    height: 3,
    backgroundColor: "red",
  },
});

export default App;

Props 🎨

| Name | Description | Type | Default Value | |----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------|:-------------------------------------------------:| | min | Minimum value for the slider. | number | required | | max | Maximum value for the slider. | number | required | | minRange | Minimum range between the low and high values. It is set to 0 if disableRange is true. | number | 0 | | step | Step value for the slider. | number | required | | low | Low value for the slider. | number | required | | high | High value for the slider. | number | required | | onValueChanged | Callback function that gets called when the slider values change. Receives the new low and high values as arguments. | (low: number, high: number) => void | required | | renderThumb | Function to render the thumb component. Accepts a type parameter which can be either high or low. | (type: 'high' or 'low') => React.ReactNode | Default Thumb | | renderRail | Function to render the rail component. | () => React.ReactNode | Default Rail | | renderRailSelected | Function to render the selected rail component. | () => React.ReactNode | Default RailSelected | | renderLowValue | Function to render the component displaying the low value. Receives the low value as an argument. | (low: number) => React.ReactNode | Default LowValueText | | renderHighValue | Function to render the component displaying the high value. Receives the high value as an argument. | (high: number) => React.ReactNode | Default HighValueText | | pannableAreaStyle | Style for the pannable area. | StyleProp<ViewStyle> | Default Pannable Area Style | | disableRange | When set to true, the slider functions as a standard slider with a single control. | boolean | false | | disabled | User interactions will be ignored when set to true. | boolean | false |

Contributions 🤝

Contributions are welcome! If you have any suggestions, feature requests, or bug reports, feel free to open an issue or submit a pull request. Let's make this component even better together! 😃

License

MIT


Made with create-react-native-library