question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Horizontal with items starting on the left

See original GitHub issue

I have been going crazy trying to adjust the slider so that the items start on the left side of the container. No mater what I try the items start centred. Here is a screenshot:

http://d.pr/i/F5lWoV

Here are the styles:

import { Dimensions } from 'react-native';

const { width: viewportWidth, height: viewportHeight } = Dimensions.get('window');

function wp(percentage) {
    const value = (percentage * viewportWidth) / 100;
    return Math.round(value);
}

const slideHeight = viewportHeight * 0.4;
const slideWidth = wp(36);
const itemHorizontalMargin = wp(2);

export const sliderWidth = viewportWidth;
export const itemWidth = slideWidth + itemHorizontalMargin * 2;

export default {
    container: {
        flex: 3,
        paddingLeft: 0,
        paddingBottom: 20,
    },
    slide: {
        flex: 1,
        height: slideHeight,
        width: itemWidth,
        justifyContent: 'center',
        paddingHorizontal: itemHorizontalMargin,
    },
    title: {
        fontSize: 13,
        marginBottom: 10,
        marginLeft: 15,
    },
    slideText: {
        color: 'white',
        fontSize: 13,
        alignSelf: 'center',
    },
};

I have tried aligning the items with containerCustomStyle and contentContainerCustomStyle but also no luck there.

Would really appreciate any guidance on this.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
gugodscommented, Mar 5, 2020

<Carousel activeSlideAlignment=‘start’ … />

5reactions
bd-arccommented, Aug 3, 2017

Hi @stueynet,

I think you’ll be very pleased to know that the flatlist branch contains just what you need (check prop activeSlideAlignment).

Note that the updated example also features a left-aligned slider, as you can see below.

react-native-snap-carousel parallax images

Read more comments on GitHub >

github_iconTop Results From Across the Web

Left align elements of horizontal list - html - Stack Overflow
However, I am having trouble trying to left align the list, so that the first element is flush left with left side of...
Read more >
Aligning items in a flex container - CSS: Cascading Style Sheets
This means that the main axis runs along the row horizontally, ... The left and right item line up flush with the start...
Read more >
Align items on the left - TeX - LaTeX Stack Exchange
1 Answer 1 ; \documentclass{article} \usepackage ; \documentclass{article} \usepackage ; \begin{itemize}[labelsep=*,leftmargin=1pc] \documentclass ...
Read more >
Bootstrap Horizontal alignment - examples & tutorial
Bootstrap 5 horizontal alignment utilities position elements on the x-axis. ... it to the start or the end of the viewport (left alignment...
Read more >
Horizontal Alignment in CSS – How to Align Elements in CSS
HTML and CSS are the first things we learn when we start Web ... We'll observe that the text gets horizontally aligned to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found