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

about scrollTo() ‘ question #25

Closed
hackerslizc opened this issue Jun 21, 2016 · 3 comments
Closed

about scrollTo() ‘ question #25

hackerslizc opened this issue Jun 21, 2016 · 3 comments

Comments

@hackerslizc
Copy link

hackerslizc commented Jun 21, 2016

import iScroll from 'iscroll/build/iscroll-probe';
import ReactIScroll from 'react-iscroll';

<ReactIScroll
    id="reactIScroll"
    ref="reactIScroll"
    iScroll={iScroll}
    onScrollEnd = {this.onScrollEnd.bind(this)}
    onScroll = {this.onScroll.bind(this)}
    options={{
        useTransition:true,
        mouseWheel: false,
        momentum: true,
        scrollbars: false,
        scrollY:true,
        scrollX:false,
        startY:scrollY
    }}>
    <div id="positionDom" className={ _Bottom ? 'hasBottom' : ''} ref="positionDom">
    {
        _list
    }
    </div>
</ReactIScroll>

gotoTopHandler(){
        var reactscroll = this.refs.reactIScroll;

        **_# PS: i want use  scrollTo() back Top like reactIScroll.scrollTo(0,0), can you tall me ,how can I do?_**

        console.log(reactscroll); 
        // reactscroll.props.iScroll.prototype.scrollTo(0,0,1000)
    }

    gotoTop (){
        return (<Tappable className="animated fadeInUp goto-top zindex-1000" component="button" onTap={this.gotoTopHandler.bind(this)}>
                    <div className="goto-top-inner">
                      <img src="../img/goto-top.png" alt=""/>
                    </div>
                </Tappable>)
    }

i want use scrollTo() back Top like reactIScroll.scrollTo(0,0), can you tall me ,how can I do?

@schovi
Copy link
Owner

schovi commented Jul 7, 2016

@hackerslizc

API for that https://github.com/schovi/react-iscroll#function-componentwithiscrollwaitforinit-callback

Usage with your case:

gotoTopHandler(){
  var reactscroll = this.refs.reactIScroll;

  reactscroll.withIScroll(function(iScroll) {
    // iScroll is now instance of iScroll and not the component
    iScroll.scrollTo(0,0)
  })
}

@schovi
Copy link
Owner

schovi commented Jul 7, 2016

Changed readme with your example. It is more self explain :)

@schovi schovi closed this as completed Jul 7, 2016
@hackerslizc
Copy link
Author

thanks for your help。

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

2 participants