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

Pull down to refresh example? #14

Open
cliffsun91 opened this issue Oct 28, 2013 · 9 comments
Open

Pull down to refresh example? #14

cliffsun91 opened this issue Oct 28, 2013 · 9 comments

Comments

@cliffsun91
Copy link

Hi, does this module support pull down to refresh? If so is there a quick example of how to do it? I've tried to follow the example from the iscroll website (http://cubiq.org/dropbox/iscroll4/examples/pull-to-refresh/) but the iscroll options involve accessing the DOM and manipulating it. I was wondering if there was a proper way to do it.

Thanks!

@diegolameira
Copy link

I'm waiting too!

@mboulord
Copy link

mboulord commented Dec 9, 2013

hi,
I write an AngularJS directive for use pull to refresh with this module:
https://github.com/mboulord/ng-iScroll-pull-to-refresh

@diegolameira
Copy link

All right, but how about ng-scroll#v1.2b and iScroll 5?

@JonnyBGod
Copy link

this is my code for both pull-to-refresh and infinite-scroll using my own version of ng-iscroll (#12) and iscroll 5

$scope.loading = search.loading;
$scope.yStartFromZero = false;

$scope.$parent.myScrollOptions = {
    'list_wrapper': {
        snap: false,
        scrollbars: 'custom',
        fadeScrollbars: true,
        probeType: 2,
        //mouseWheel: true,
        interactiveScrollbars: true,
        //preventDefault: false,
        on: [
            { beforeScrollStart: function () {
                if (this.y === 0) {
                    $scope.yStartFromZero = true;
                }

            }},
            { scrollEnd: function () {
                if ($scope.yStartFromZero && this.directionY === -1) {
                    this._execEvent("pullToRefresh");
                }
                $scope.yStartFromZero = false;
                $scope.infiniteScroll = false;
            }},
            { pullToRefresh: function () {
                console.log('Pull to Refresh!');
            }},
            { scroll: function () {
                if (!$scope.infiniteScroll && !search.loading && !search.endlist && (this.y <= this.maxScrollY + 800)) {
                    $scope.infiniteScroll = true;
                    search.__search();
                }
            }}
        ]
    }
}; 

@vaskgjuri
Copy link

JonnyBGod, thanks for the JS snippet. Could you provide the HTML as well on how do you use it as whole example? I am having trouble with this code as I tried to implement it in my case but have struggled with it.

BR

@JonnyBGod
Copy link

Sure, my html is as simple as:

<div ng-iscroll='list_wrapper'>
  <div>
    <div class="YOUR CONTENT" ng-repeat="i in items track by i.id">
    </div>
  <div>
</div>

@vaskgjuri
Copy link

I thought my problem was with the html implementation but it seems like we are ok on that side. The problem I am having is that the pull down to refresh does not load on initial page load, but rather when I refresh the view. Any thoughts on why could this be happening?

BR

@orenagiv
Copy link

I've prepared a demo - hope this helps:
http://pnc.co.il/dev/iscroll-5-pull-to-refresh-and-infinite-demo.html

The DEMO includes both Pull to Refresh and "infinite" scroll (but not using the iscroll-infinite.js).

@pmadhu420
Copy link

pmadhu420 commented Aug 27, 2016

Hi,
I am using iscroll5 and TopOffset is not working and i am pasting my code and pull to refresh is not working can any one help me and make necessary change to work pull to refresh and it is an urgent requirement for production fix.

function createScroller(wrapper, pullDownAction, scrollStart, scrollMove, scrollEnd, beforeScrollStart, enableBeforeScrollStart) {
var myScroll, pullDownEl, pullDownOffset = 0;

        var wrapperEl = typeof wrapper == 'object' ? wrapper : doc.getElementById(wrapper);
        var scrollerEl = wrapperEl.children[0];
        $(scrollerEl).prepend("<div class='pullDown'></div>");
        pullDownEl = $(scrollerEl).find('.pullDown')[0];
        pullDownOffset = pullDownEl.offsetHeight;
        myScroll = new IScrollV5(wrapper, {
            mouseWheel: true,
            hideScrollbar: true,
            fadeScrollbar: true,
            useTransition: true,
            click: true,
            scrollbarClass: 'Scrollbar',
            topOffset: pullDownOffset,
        });
        myScroll.on("scrollMove", function () {
            if (this.y > 5 && !pullDownEl.className.match('flip')) {
                pullDownEl.className = 'flip';
                this.minScrollY = 0;
            } else if (this.y < 5 && pullDownEl.className.match('flip')) {
                pullDownEl.className = '';
                this.minScrollY = -pullDownOffset;
            }
            if (scrollMove != undefined)
                scrollMove();
        });
        myScroll.on("scrollEnd", function () {
            if (pullDownEl.className.match('flip')) {
                pullDownEl.className = 'pullDownloading';
                pullDownAction(this);
            }
            if (scrollEnd != undefined)
                scrollEnd();
        });
        myScroll.on("refresh", function () {
            if (pullDownEl.className.match('pullDownloading')) {
                pullDownEl.className = '';
            }
        });
    }

    return myScroll;

}
var scroller = {
createScroller: createScroller,
}

return scroller;

});

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

7 participants