Files
ionic-framework/js/views/loadingView.js
2013-10-21 16:57:18 -05:00

47 lines
1.1 KiB
JavaScript

(function(ionic) {
'use strict';
/**
* An ActionSheet is the slide up menu popularized on iOS.
*
* You see it all over iOS apps, where it offers a set of options
* triggered after an action.
*/
ionic.views.Loading = function(opts) {
var _this = this;
this.el = opts.el;
this.maxWidth = opts.maxWidth || 200;
this._loadingBox = this.el.querySelector('.loading');
};
ionic.views.Loading.prototype = {
show: function() {
var _this = this;
if(this._loadingBox) {
//window.requestAnimationFrame(function() {
var lb = _this._loadingBox;
var width = Math.min(_this.maxWidth, Math.max(window.outerWidth - 40, lb.offsetWidth));
lb.style.width = width;
lb.style.marginLeft = (-lb.offsetWidth) / 2 + 'px';
lb.style.marginTop = (-lb.offsetHeight) / 2 + 'px';
_this.el.classList.add('active');
//});
}
},
hide: function() {
// Force a reflow so the animation will actually run
this.el.offsetWidth;
this.el.classList.remove('active');
}
};
})(ionic);