Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React Native Web support #126

Open
ButuzGOL opened this issue Aug 7, 2018 · 1 comment
Open

React Native Web support #126

ButuzGOL opened this issue Aug 7, 2018 · 1 comment

Comments

@ButuzGOL
Copy link

ButuzGOL commented Aug 7, 2018

Have tried to render in web
found issues

  1. cant resolve DoneButton.ios => DoneButton
  2. Swiper borders
  3. Not swiping and moving by dots

screen shot 2018-08-07 at 8 30 47 am

@ButuzGOL
Copy link
Author

ButuzGOL commented Aug 8, 2018

did some updates and it works

import React from 'react';

import { StatusBar, View, Animated } from 'react-native';
import AppIntro from 'react-native-app-intro';

import Swiper from './Swiper';

export default class AppIntroWrapper extends AppIntro {
  onNextBtnClick = (context) => {
    if (context.state.isScrolling || context.state.total < 2) return;
    const { state } = context;
    const diff = (context.props.loop ? 1 : 0) + 1 + context.state.index;
    let x = 0;
    if (state.dir === 'x') x = diff * state.width;

    context.refs.scrollView.scrollTo({ y: 0, x });
    this.props.onSlideChange(context.state.index + 1, context.state.total);

    this.props.onNextBtnClick(context.state.index);
  };
  render() {
    const childrens = this.props.children;
    const { pageArray } = this.props;
    let pages = [];
    if (pageArray.length > 0) {
      pages = pageArray.map((page, i) => this.renderBasicSlidePage(i, page));
    } else {
      pages = childrens.map((children, i) => this.renderChild(children, i, i));
    }

    return (
      <View style={{ position: 'static' }}>
        <Swiper
          loop={false}
          width={960}
          height="100vh"
          index={this.props.defaultIndex}
          renderPagination={this.renderPagination}
          onMomentumScrollEnd={(e, state) => {
            if (this.isToTintStatusBar()) {
              StatusBar.setBackgroundColor(
                this.shadeStatusBarColor(this.props.pageArray[state.index].backgroundColor, -0.3),
                false,
              );
            }

            this.props.onSlideChange(state.index, state.total);
          }}
          onScroll={Animated.event([{ x: this.state.parallax }])}
        >
          {pages}
        </Swiper>
      </View>
    );
  }
}
import React from 'react';

import { ScrollView, StyleSheet, View } from 'react-native';
import Swiper from 'react-native-swiper';

const styles = StyleSheet.create({
  wrapper: {
    backgroundColor: 'transparent',
  },
});

export default class SwiperWrapper extends Swiper {
  renderScrollView = pages => (
    <ScrollView
      ref="scrollView"
      {...this.props}
      style={{ overflowX: 'hidden' }}
      contentContainerStyle={[styles.wrapper, this.props.style, { overflow: 'hidden' }]}
      contentOffset={this.state.offset}
      onScrollBeginDrag={this.onScrollBegin}
      onMomentumScrollEnd={this.onScrollEnd}
      onScroll={this.onScroll}
      scrollEventThrottle={16}
    >
      {pages}
    </ScrollView>
  );
}
extensions: ['.ios.js']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant