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

Is there a way to see if there is already a banner in view? #38

Open
aubrey-fowler opened this issue Jun 8, 2017 · 1 comment
Open

Comments

@aubrey-fowler
Copy link

I have an issue in my app where if there are 2 errors happening at the same time then I get 2 banners overlapping each other and I can't see the error messages. Is there a way to check if there is already an open banner? Angular 1.5.3

                var showContentBanner = function (type, message) {
   $ionicContentBanner.show({
                            text: data,
                            type: type,
                            interval: 3000,
                            transition: 'vertical'
                        });

```}
@leob
Copy link
Contributor

leob commented Sep 6, 2017

Hi (writing here instead of replying to your direct message) ...

I'm not familiar with the internals of the component, but I just looked at https://github.com/djett41/ionic-content-banner/blob/master/js/ionic.content.banner.service.js and my best bet would be to "somehow" override the "scope.show()" and "scope.close()" methods.

Not sure how to do that (my Angular 1 is a bit rusty) apart from just forking the component for yourself and changing the source, maybe there's a better way so you don't have to modify the original source.

Anyway, assuming that you can hook into "scope.show()" and "scope.close()" then the solution becomes simple, you can either set a "flag" (e.g. in the $scope or whatever) that you set to true when the banner is shown and false when it's not, or you introduce two events ("onshow" and "onhide") that you can listen to in your Angular page.

Another approach (this is sort of a hack but it would not require modifying the source) is to check the DOM to see if the element(s) associated with the content banner is present/visible or not (probably this is the easiest way).

You then need a way to "postpone" your second banner invocation until the first one has "finished" (isn't visible anymore) ... that is, you need to "serialize" the two calls (make them serial instead of parallel) ... this would probably be achieved most easily with events and/or a timer.

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