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

Delay display of Loading overlay for 'showDelay' ms #562

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions js/views/loadingView.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(function(ionic) {
'use strict';
/**
* An ActionSheet is the slide up menu popularized on iOS.
* Loading
*
* You see it all over iOS apps, where it offers a set of options
* triggered after an action.
* The Loading is an overlay that can be used to indicate
* activity while blocking user interaction.
*/
ionic.views.Loading = ionic.views.View.inherit({
initialize: function(opts) {
Expand All @@ -14,6 +14,8 @@

this.maxWidth = opts.maxWidth || 200;

this.showDelay = opts.showDelay;

this._loadingBox = this.el.querySelector('.loading');
},
show: function() {
Expand All @@ -29,13 +31,19 @@
lb.style.marginLeft = (-lb.offsetWidth) / 2 + 'px';
lb.style.marginTop = (-lb.offsetHeight) / 2 + 'px';

_this.el.classList.add('active');
// Wait 'showDelay' ms before showing the loading screen
this._showDelayTimeout = window.setTimeout(function() {
_this.el.classList.add('active');
}, _this.showDelay);
}
},
hide: function() {
// Force a reflow so the animation will actually run
this.el.offsetWidth;

// Prevent unnecessary 'show' after 'hide' has already been called
window.clearTimeout(this._showDelayTimeout);

this.el.classList.remove('active');
}
});
Expand Down