What way can that code trigger animation on ion-refresher?

#1

Hi ionic team!
What way can that code trigger animation on ion-refresher?

#2

What code? I’m not seeing anything.

#3

Like this animation

#4

Take a look at this, ion-refresher.

#5

This animation is mouse triggered.
I hope that have code can trigger animation on ion-refresher.

#6

Not API support ! What can I do?

#7

Hey there, so what is it that you are trying to do? Use our pull-to-refresh?

#9

I need click options of left list, then trigger ion-refresher animation.

#10

If you just need the animation and not the loading function, you can use a simple ng-if.

#11

May be I express wrong. I apologize in advance.
I want what API or code trigger pull-to-refresh(ion-refresher).
Could ion-refresher only pull triggered?

#12

Ah alright, yeah.

Yes, ion-refresher functionality, that is - the pulling down to load more content - is only available on with that component.

#13

Hi mhartington.
Could Ionic team can provide code trigger pull-to-refresh functionality ?
Like this: https://github.com/samvermette/SVPullToRefresh([tableView triggerPullToRefresh])
I need this function.This function should is Widespread small demand.

#14

Like this?

#15

Could I click cell trigger pull-to-refresh?

#16

Yeah, but that does kind of defeat the purpose.

#17

But,this way is easy be problem!

Whether can don’t creat new element , only on pull-to-refresh(ion-refresher) triggered?

#18

Then you can do this.

  <ion-refresher ng-if="!show.icon" 
                 on-refresh="doRefresh()"
                 pulling-text="Pull to refresh..."
                 refreshing-text="Refreshing!"
                 refreshing-icon="ion-loading-c">

  </ion-refresher>
#19

thank you, I’ve tested. I feel such an interactive way or not. I think I need to change the kind of interaction!

#21

This would actually be super helpful. Whenever a user loads my page for the first time, I need to hit the API and pull in my list. I would love to display a loading spinner while that refresh happens.

Then, later, I also want users to be able to manually refresh the list with a pull-to-refresh. This should also display the loading spinner.

Currently, I need 2 separate loading spinners in order to achieve this, because I cannot manually trigger pull-to-refresh to display. Yes, I can use the same function in the controller to make the actual API call, but I need two spinners in my template for this to work! Wouldn’t it be nice if I could just call $ionRefresher.pull() on first page load, and have it take care of everything?

2 Likes
#22

I was poking around looking at how the refresher works and came across a function called triggerPullToRefresh. It looks like they are working on this feature but it didn’t quite work for me. So I did some more poking around and came up with a solution that worked for me:

angular.module('YourApp').service('utilities', function() {

    this.triggerScrollViewPullToRefresh = function (scrollView) {
        scrollView.__publish(
            scrollView.__scrollLeft, -scrollView.__refreshHeight,
            scrollView.__zoomLevel, true);

        var d = new Date();

        scrollView.refreshStartTime = d.getTime();

        scrollView.__refreshActive = true;
        scrollView.__refreshHidden = false;
        if (scrollView.__refreshShow) {
            scrollView.__refreshShow();
        }
        if (scrollView.__refreshActivate) {
            scrollView.__refreshActivate();
        }
        if (scrollView.__refreshStart) {
            scrollView.__refreshStart();
        }
    }
});

Just call that function passing in your scroll view and it should trigger the display of the refresher. Use the normal event to dismiss it. Keep in mind this will also trigger your onPulling and onRefresh callbacks. Also keep in mind this is using private variables and functions that may change and break this in the future. I suspect at some point they will fix the triggerPullToRefresh though.