meteor-ionic/components/ionBackdrop/ionBackdrop.js
2014-12-17 08:23:16 -08:00

32 lines
743 B
JavaScript

IonBackdrop = {
holds: 0,
retain: function () {
this.holds++;
if (this.holds === 1) {
this.template = Template['ionBackdrop'];
this.view = Blaze.renderWithData(this.template, {}, $('.ionic-body').get(0));
var $backdropEl = $(this.view.firstNode());
$backdropEl.addClass('visible');
Meteor.setTimeout(function () {
$backdropEl.addClass('active');
}, 10);
}
},
release: function () {
this.holds--;
if (this.holds === 0) {
var $backdropEl = $(this.view.firstNode());
$backdropEl.removeClass('active');
Meteor.setTimeout(function () {
$backdropEl.removeClass('visible');
Blaze.remove(this.view);
}.bind(this), 400);
}
}
};