React-native-slider: How to adjust the size of the thumb button

Created on 16 Aug 2019  路  20Comments  路  Source: callstack/react-native-slider

...
<Slider
    style={styles.scheduleBar}
    minimumValue={0}
    maximumValue={120}
    minimumTrackTintColor="#FFFFFF"
    maximumTrackTintColor="#000000"
    thumbImage={'../styles/dark/dot.png'}
    step={1}
 />
...

How to adjust the size of the thumb button锛孖 checked the issue and found no useful information. Now it works on my page, but the thumb button is too big and looks very ugly

question

Most helpful comment

I'm solving this issue using an icon as image since I have installed react-native-vector-icons.

Icon.getImageSource('circle', 15, 'white')
   .then(source => this.setState({ thumbIcon: source }));

later in Slider component

<Slider
   ...
   thumbImage={this.state.thumbIcon}
/>

The thumb shows the size and color specified on getImageSource method.

All 20 comments

+1

I've found it'll be whatever the size of your image natively is -- reduce the image dimensions and it'll go down in the app too (bad solution I know :( )

I think there should be a prop for the thumb size. This is very basic.

+1

+1

I'm solving this issue using an icon as image since I have installed react-native-vector-icons.

Icon.getImageSource('circle', 15, 'white')
   .then(source => this.setState({ thumbIcon: source }));

later in Slider component

<Slider
   ...
   thumbImage={this.state.thumbIcon}
/>

The thumb shows the size and color specified on getImageSource method.

transform: [{scaleX: 0.3}, {scaleY: 0.3}],

I'm solving this issue using an icon as image since I have installed react-native-vector-icons.

Icon.getImageSource('circle', 15, 'white')
   .then(source => this.setState({ thumbIcon: source }));

later in Slider component

<Slider
   ...
   thumbImage={this.state.thumbIcon}
/>

The thumb shows the size and color specified on getImageSource method.

This didn't work for me. getImageSource() gets called indefinitely and caused my app UI to be completely blocked.

I'm solving this issue using an icon as image since I have installed react-native-vector-icons.

Icon.getImageSource('circle', 15, 'white')
   .then(source => this.setState({ thumbIcon: source }));

later in Slider component

<Slider
   ...
   thumbImage={this.state.thumbIcon}
/>

The thumb shows the size and color specified on getImageSource method.

This didn't work for me. getImageSource() gets called indefinitely and caused my app UI to be completely blocked.

Maybe you're calling Icon.getImageSource into render function?
try something like

import React, { useState, useEffect } from 'react';

const MyComponent = () => {
  const [icon, setIcon] = useState();

  useEffect(() => {
    Icon.getImageSource('circle', 15, 'white')
     .then(setIcon);
  }, []);

  <Slider
    ...
    thumbImage={icon}
  />
};

or use the equivalent componentDidMount in class component approach. The idea is that getImageSource's callback is affecting the state and render the component again, so move Icon.getImageSource() call outside the render loop.

The team should need to give access to change thumb size

Thumb size would be very useful to change as a property

+1

+1 for this feature !

+1

+1

+1

Please add this feature, it is very important. Thanks.

Any plans on adding this feature?

Bump :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lolcookie picture lolcookie  路  7Comments

canyavall picture canyavall  路  5Comments

cpojer picture cpojer  路  6Comments

akrger picture akrger  路  6Comments

vinithreddy3 picture vinithreddy3  路  5Comments