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

Progress.Bar progress starting from center

Open jeremy303 opened this issue 6 years ago • 8 comments

Progress.Bar is rendering with the progress beginning from near the middle of the bar, then expanding to fill the bar at 100% as demonstrated in this screenshot:

image

Any ideas what's going on here? I've experimented with various styles and Progress.Bar properties and nothing seems to change the behavior.

This is with "react-native": "0.61.4", running in the iOS Simulator (iPad 7, OS 13.3)

Here's a subset of my code that at least demonstrates how I'm using the progress bar in the layout and it's styling, although this code isn't functional as I quickly extracted the rest of my non-relevant view code:

import React, { Component } from 'react';
import {
  StyleSheet,
  SafeAreaView,
} from 'react-native';
import { WebView } from 'react-native-webview';
import * as Progress from 'react-native-progress';
import type { WebBrowser } from './WebBrowser';

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  webView: {
    flex: 1,
  },
  progressBar: {
    position: 'absolute',
    flex: 1,
    top: 0,
    height: 6,
    width: '100%',
    borderRadius: 0,
  },
});

/**
 * View for content reading.
 */
export default
class ContentReaderView extends Component<{
  viewModel: ContentReaderViewModel,
}>
  render() {
    const { viewModel } = this.props;
    return (
      <SafeAreaView style={styles.container}>
        <WebView
          style={styles.webView}
        />
        { viewModel.isLoading && (
          <Progress.Bar
            style={styles.progressBar}
            progress={viewModel.loadProgress}
          />
        }
      </SafeAreaView>
    );
  }
}

jeremy303 avatar Jan 19 '20 20:01 jeremy303

Have you tried to use a random number for the progress property? I also tried your styling and as you said it works fine, but instead of what you have for progress I used a random number

Dianaqqq avatar Jan 31 '20 10:01 Dianaqqq

@HolySamosa, can you please try setting width as null instead of handling it via CSS?

<Progress.Bar
    width={null}
    style={styles.progressBar}
    progress={viewModel.loadProgress}
/>

Reference: https://github.com/oblador/react-native-progress#progressbar

For width property:

Full width of the progress bar, set to null to use automatic flexbox sizing.

I hope that solves your problem; if not, please let me know. :)

kunalmhatre avatar Feb 10 '20 14:02 kunalmhatre

Thanks @kunalmhatre

hardikramoliya avatar Mar 03 '20 03:03 hardikramoliya

Whoops. Somehow I missed the earlier notifications for this thread. @kunalmhatre, I'll give your suggestion a try. @hardikramoliya, did you have the same issue and did this solve your problem?

Thanks!

jeremy303 avatar Mar 03 '20 14:03 jeremy303

Thanks, @kunalmhatre. That did the trick!

jeremy303 avatar Mar 04 '20 19:03 jeremy303

I had the same issue with width={null}. I had to remove the onLayout parameter from the PgoressBar component and move it to a parent View to solve it

d-baranowski avatar Apr 05 '21 09:04 d-baranowski

I had the same issue with width={null}. I had to remove the onLayout parameter from the PgoressBar component and move it to a parent View to solve it

That is because if you put onLayout on the Bar component itself, it will overwrite the wrong function. As a result, the this.handleLayout will be overriden by the function you provided:

https://github.com/oblador/react-native-progress/blob/master/Bar.js#L171

pdpd123 avatar Apr 10 '21 06:04 pdpd123

width={''} This worked for me

umerdogar avatar Apr 24 '24 21:04 umerdogar