Skip to content

Commit

Permalink
Add Snackbar hide method
Browse files Browse the repository at this point in the history
  • Loading branch information
joaofnds authored and Garbee committed Feb 24, 2017
1 parent fd21836 commit 03120bb
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/snackbar/snackbar.js
Expand Up @@ -38,6 +38,7 @@
this.actionHandler_ = undefined;
this.message_ = undefined;
this.actionText_ = undefined;
this.timeoutID_ = undefined;
this.queuedNotifications_ = [];
this.setActionHidden_(true);
};
Expand Down Expand Up @@ -86,7 +87,7 @@
this.textElement_.textContent = this.message_;
this.element_.classList.add(this.cssClasses_.ACTIVE);
this.element_.setAttribute('aria-hidden', 'false');
setTimeout(this.cleanup_.bind(this), this.timeout_);
this.timeoutID_ = setTimeout(this.cleanup_.bind(this), this.timeout_);

};

Expand Down Expand Up @@ -127,7 +128,21 @@
}
};
MaterialSnackbar.prototype['showSnackbar'] = MaterialSnackbar.prototype.showSnackbar;

/**
* Hide the snackbar.
*
* @public
*/
MaterialSnackbar.prototype.hideSnackbar = function() {
if (!this.active) {
return;
}
if (typeof this.timeoutID_ === 'number') {
clearTimeout(this.timeoutID_);
this.cleanup_();
}
};
MaterialSnackbar.prototype['hideSnackbar'] = MaterialSnackbar.prototype.hideSnackbar;
/**
* Check if the queue has items within it.
* If it does, display the next entry.
Expand Down Expand Up @@ -158,6 +173,7 @@
this.actionHandler_ = undefined;
this.message_ = undefined;
this.actionText_ = undefined;
this.timeoutID_ = undefined;
this.active = false;
this.checkQueue_();
}.bind(this), /** @type {number} */ (this.Constant_.ANIMATION_LENGTH));
Expand Down

2 comments on commit 03120bb

@garnold
Copy link

@garnold garnold commented on 03120bb Mar 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joaofnds @Garbee I was just looking for this functionality! Are you going to cut a new release?

@MarcelRobitaille
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea when this will get into a release?

Please sign in to comment.