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

support indicators option? #33

Open
orlowang opened this issue Oct 9, 2016 · 7 comments
Open

support indicators option? #33

orlowang opened this issue Oct 9, 2016 · 7 comments
Labels

Comments

@orlowang
Copy link

orlowang commented Oct 9, 2016

can it be possiable to supoort options.indicators? I have noticed that this repo is not update for a long time. and I was really interested in this project, I am grateful that you can have a look about this.

@schovi
Copy link
Owner

schovi commented Oct 17, 2016

@OWCC indicators are some kind of parallax thing. When you scroll main element other elements (which are indicators) will scroll too with modification of speed.
As I read in documentation, you can pass elements or selectors. Element is not friendly way in React (maybe I am just oldfashioned, but refs arent good), but selectors might work. Can you try it if you have running project?

@schovi
Copy link
Owner

schovi commented Oct 18, 2016

I am currently implementing all demos from original iscroll, then I will see all the usecases and how to deal with them.

@lemming
Copy link

lemming commented Oct 29, 2016

Element is not friendly way in React (maybe I am just oldfashioned, but refs arent good), but selectors might work. Can you try it if you have running project?

I tried with selectors - it works, though produces warning message in console:
Warning: Failed prop type: Invalid prop options.indicatorssupplied toReactIScroll.

@schovi
Copy link
Owner

schovi commented Nov 1, 2016

@lemming Can you show me config?

@schovi schovi added the question label Nov 1, 2016
@lemming
Copy link

lemming commented Nov 1, 2016

Sorry, ended up using iScroll directly because of need to avoid instantiation of iScroll on every render, so no config left. But either selectors or refs working, though one should be careful with lifecycle in the latter case (ref have to be available before options object gets created and <ReactIScroll/> mounts).

In terms of usage example from readme it could be something like this:

var React = require('react'),
    ReactIScroll = require('react-iscroll'),
    iScroll = require('iscroll');

var ExampleApp = React.createClass({
  getDefaultProps: function() {
    return ({
      options: {
        mouseWheel: true,
        scrollbars: true,
        // add indicators section to options
        indicators: [{
          el: '#indicator', // selector of the indicator container
          resize: false,
          ignoreBoundaries: true,
          speedRatioY: 0.5
        }]

      }
    })
  },
  onScrollStart: function() {
    console.log("iScroll starts scrolling")
  },
  render: function() {
    var i = 0, len = 1000, listOfLi = [];

    for(i; i < len; i++) {
      listOfLi.push(<li key={i}>Row {i+1}</li>)
    }

    return (
      <div>
        {/* just add indicator with id */}
        <div id="indicator" style={{ position: 'absolute', top: 0, left: 0, bottom: 0, right: 0, overflow: 'hidden'}}>
          <div style={{position: 'absolute', overlow: 'hidden', transform: 'translateZ(0)', width: '100%'}}>Indicator contents</div>
        </div>
        <div style={height: '100vh'}>
          <h1>Example of scrollable list</h1>
          <ReactIScroll iScroll={iScroll}
                      options={this.props.options}
                      onScrollStart={this.onScrollStart}>
            <ul>
              {listOfLi}
            </ul>
          </ReactIScroll>
        </div>
      </div>
    )
  }
})

@schovi
Copy link
Owner

schovi commented Nov 2, 2016

Indicators are really special in case of React. It is some components somewhere. Maybe making some helper component would help to manage it.

@robinwkurtz
Copy link

Hello, I'm also getting an Invalid prop error.

Warning: Failed prop type: Invalid prop options.indicatorssupplied toReactIScroll.

Options:

options: {
	startX: 0,
	startY: 0,
	scrollX: true,
	scrollY: false,
	indicators: [{
		el: document.getElementById('productWrapperInner'),
		listenX: true,
		listenY: false,
		interactive: true,
		shrink: 'clip',
		fade: true
	}],
	probeType: 2,
	directionLockThreshold: 5,
	freeScroll: false,
	disableMouse: false,
	mouseWheel: true,
	disableMouse: true,
	momentum: true,
	deceleration: 0.05,
	bounceTime: 800,
	eventPassthrough: true,
	reverseHorizontalScroll: true,
	wheelHorizontal: true,
	slideWidth: 180,
}

Any thoughts? solutions D:

Thanks!

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

No branches or pull requests

4 participants