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 Support #38

Merged
merged 6 commits into from
Nov 3, 2016
Merged

React Support #38

merged 6 commits into from
Nov 3, 2016

Conversation

lyfeyaj
Copy link
Owner

@lyfeyaj lyfeyaj commented Nov 2, 2016

Usage

Prerequisite

Install swipejs via npm install swipejs

Example

'use strict';

import React from 'react';
import { Swipe, SwipeItem } from 'swipejs/react';

class HomePage extends React.Component {
  constructor(...args) {
    super(...args);
    this.state = {};
  }

  componentDidMount() {
    let mySwipe = this.refs.swipe.instance;
    // You can call swipe methods on `mySwipe`
    // mySwipe.prev()
    // mySwipe.next()
    // mySwipe.getPos()
    // mySwipe.getNumSlides()
    // mySwipe.slide()
    // mySwipe.restart()
    // mySwipe.stop()
    // mySwipe.kill()
  }

  onTransactionEnd(index, elem) {
    // Your own logic
  }

  handleCallback(index, elem) {
    // Your own logic
  }

  handleClick(e) {
    // Your own logic
  }

  render() {
    return (
      <Swipe className='custom-swipe-container-class'
             ref='swipe'
             startSlide={0}
             speed={300}
             auto={3000}
             draggable={false}
             continuous={true}
             autoRestart={false}
             disableScroll={false}
             stopPropagation={false}
             callback={this.handleCallback.bind(this)}
             transitionEnd={this.onTransactionEnd.bind(this)}>
        <SwipeItem className='custom-swipe-item-class'
                   onClick={this.handleClick.bind(this)}>
          Slide One
        </SwipeItem>
        <SwipeItem className='custom-swipe-item-class'
                   onClick={this.handleClick.bind(this)}>
          Slide Two
        </SwipeItem>
        <SwipeItem className='custom-swipe-item-class'
                   onClick={this.handleClick.bind(this)}>
          Slide Three
        </SwipeItem>
      </Swipe>
    );
  }
}

@lyfeyaj lyfeyaj mentioned this pull request Nov 2, 2016
@lyfeyaj
Copy link
Owner Author

lyfeyaj commented Nov 2, 2016

@loup-brun Any advice on this PR?

@pcg92
Copy link

pcg92 commented Nov 2, 2016

Thank you! m going to try it just now

@pcg92
Copy link

pcg92 commented Nov 2, 2016

Im getting this problem:

swipe.js:63 Uncaught TypeError: Cannot assign to read only property 'continuous' of object '#

options.continuous = options.continuous !== undefined ? options.continuous : true;

@pcg92
Copy link

pcg92 commented Nov 2, 2016

I cant use this component, the dom is rendered but on the browser i didnt see anything

@loup-brun
Copy link
Collaborator

@lyfeyaj Haven't worked with React... I'll look into it if I have time!

@lyfeyaj
Copy link
Owner Author

lyfeyaj commented Nov 3, 2016

@pcegarra Fixed

@lyfeyaj lyfeyaj merged commit f9bef15 into master Nov 3, 2016
@lyfeyaj lyfeyaj deleted the feature/react-component branch November 4, 2016 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants