Skip to content

Instantly share code, notes, and snippets.

@lucaszmoraes
Created October 25, 2023 13:30
Show Gist options
  • Save lucaszmoraes/9bcbf794bdcad1d207ff7e7ccb7192d6 to your computer and use it in GitHub Desktop.
Save lucaszmoraes/9bcbf794bdcad1d207ff7e7ccb7192d6 to your computer and use it in GitHub Desktop.
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i(require("@hotwired/stimulus"),require("stimulus-use")):typeof define=="function"&&define.amd?define(["@hotwired/stimulus","stimulus-use"],i):(e=typeof globalThis<"u"?globalThis:e||self,e.StimulusNotification=i(e.Stimulus,e.useTransition))})(this,function(e,i){"use strict";class t extends e.Controller{initialize(){this.hide=this.hide.bind(this)}connect(){i.useTransition(this),this.hiddenValue===!1&&this.show()}show(){this.enter(),this.timeout=setTimeout(this.hide,this.delayValue)}async hide(){this.timeout&&clearTimeout(this.timeout),await this.leave(),this.element.remove()}}return t.values={delay:{type:Number,default:3e3},hidden:{type:Boolean,default:!1}},t});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment