djett41 / ionic-content-banner

An informational content banner for Ionic applications
MIT License
84 stars 25 forks source link

Banner with no text: Wrapped inside a function #16

Open pliablepixels opened 9 years ago

pliablepixels commented 9 years ago

There is a separate issue (https://github.com/djett41/ionic-content-banner/issues/15) asking the same thing, but the added caveat is I have wrapped the function around in a service for convenience.

Every once in a while, the banner shows up with the background but no text

Here is my factory function. I tried looking at the code, but your use of angular is way beyond my current knowledge of it.

My service code:

     function displayBanner (mytype, mytext, myinterval, mytimer)
        {

            console.log ("SERVICE DISPLAY: " + JSON.stringify(mytext));
            console.log ("SERVICE DISPLAY: interval:" + myinterval + " timer:" + mytimer);
            var contentBannerInstance =
            $ionicContentBanner.show({
              text: mytext || 'no text',
              interval: myinterval || 2000,
              autoClose: mytimer || 6000,
              type: mytype || 'info',
              transition: 'vertical',
              //cancelOnStateChange: false
            });

            /*$timeout (function() {
                contentBannerInstance();
            },mytimer || 6000);*/
    }

As you see, inside my wrapper I am printing out the value of the text and its filled in each time. I'm pulling my hair out trying to figure this out.

I invoke it like this:

ZMDataModel.displayBanner('alarm', eventsToDisplay, 5000, 5000*eventsToDisplay.length);

where eventsToDisplay is an array of text.

It works sometimes and does not work sometimes.

Does this have anything to do with a service wrapper? Something to do with scopes maybe?

thanks

pliablepixels commented 9 years ago

If it helps, I think what is happening is that the text does come, but it takes time and if the banner disappears before that, then one thinks its an empty banner - I have no idea why the text gets delayed

pliablepixels commented 9 years ago

Some more debugging - it does not seem to be a factory issue. I removed the factory invocation and directly put in

var contentBannerInstance =
            $ionicContentBanner.show({
              text: eventsToDisplay,
              interval: 5000,
              autoClose: 5000*eventsToDisplay.length,
              type: 'alarm',
              transition: 'vertical',
              //cancelOnStateChange: false
            });

What seems to be happening is it starts off fine for the first few invocations.Then there is a slight delay in text. And then suddenly the text doesn't come. And then sometime later it shows up again, and then the loop continues. It seems to me the text display timer is not being cleared somewhere.

pliablepixels commented 9 years ago

Okay, this seems to be an 'iOS only' problem. Never occurs in Android. I am running iOS9