react-native-slider icon indicating copy to clipboard operation
react-native-slider copied to clipboard

thumbImage not displaying

Open 1ak31sha opened this issue 7 years ago • 12 comments

Hi, I am trying to use a png as the thumbImage o the slider, but I cant seem to get it to work. I am using example 9 and just replaced the image path with my own:

        <Slider
          minimumTrackTintColor='#13a9d6'
          thumbImage={require('./slider_thumbnail.png')}
          thumbStyle={customStyles9.thumb}
          thumbTintColor='#0c6692'
          value={this.state.value}
          onValueChange={(value) => this.handleValueChange(value)}
        />

All i get is the styling from example#9 but my png is not displayed anywhere Any ideas or how to debug?

1ak31sha avatar Jul 31 '17 18:07 1ak31sha

+1

lvxinyi avatar Aug 17 '17 07:08 lvxinyi

you could probably take a stab at fixing this by adding some styles to the <Image> in src/slider.js.

the only code in there for the image are the image being passed into the slider and these lines

_renderThumbImage = () => { // async function call
    var {thumbImage} = this.props; // grab image var from props
    if (!thumbImage) return; // if null do nothing
    return <Image source={thumbImage} />; // if not null then return a basic image object with no styling. 
};

as you can see, no styles added, so add style={{resizeMode: 'contain'}} to the Image or some other code and youll probably get the result you want(i am not sure 100% what to add, my slider.js is 878 lines and heavily edited).

Make sure you take a copy of the slider.js or move it out of node_modules though because every run of yarn or npm install will replace the slider.js with its original.

nuttylord avatar Aug 17 '17 08:08 nuttylord

+1

Yonatani avatar Aug 23 '17 08:08 Yonatani

+1

TracyYangg avatar Sep 26 '17 08:09 TracyYangg

+1

FMdigit avatar Dec 30 '17 08:12 FMdigit

The same problem, did anyone tried solution above? Did it help?

Luckygirlllll avatar Jul 31 '18 09:07 Luckygirlllll

Same here

ScreamZ avatar Apr 05 '19 09:04 ScreamZ

I'm still having this issue :(

mkecman avatar Aug 09 '19 12:08 mkecman

One thing that helped me fix this issue is to use one of thumbImage or thumbTintColor attribute of Slider. When you use both, the thumbTintColor dominates or overlays the image at unpredictable times.

karthiks avatar Sep 27 '20 17:09 karthiks

One thing that helped me fix this issue is to use one of thumbImage or thumbTintColor attribute of Slider. When you use both, the thumbTintColor dominates or overlays the image at unpredictable times.

Thanks @karthiks This helped me a lot. I was struggling to fix it for a while.

kcpal avatar May 08 '21 09:05 kcpal

Hi, I am facing the same issue, I just used the <Image/> to verify the image path and all, it was all good but it's not visible on the slider thumImage.

<Slider
              style={{width: 256, height: 25}}
              minimumValue={0}
              maximumValue={2}
              minimumTrackTintColor="#00000000"
              maximumTrackTintColor="#0000001A"
              step={1}
              value={1}
              onValueChange={(index)=>slideHandler(index)}
              thumbImage={require("./../../imagesv2/feedbackModel/Thumnil.png")}
              // trackImage={require("./../../imagesv2/feedbackModel/Track.png")}
            />

SSOURABH58 avatar Oct 11 '21 12:10 SSOURABH58

sorry for the trouble I fix it, the thumbImage prop only uses uri not require.

import thumImage from './../../imagesv2/feedbackModel/Thumnil.png'
const ThumImageUri = Image.resolveAssetSource(thumImage).uri

SSOURABH58 avatar Oct 11 '21 13:10 SSOURABH58