click-outside.js 635 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.ClickOutsideMixin = void 0;
  4. var _event = require("../utils/event");
  5. var ClickOutsideMixin = function ClickOutsideMixin(config) {
  6. return {
  7. mounted: function mounted() {
  8. var _this = this;
  9. config.handler = function (event) {
  10. if (!_this.$el.contains(event.target)) {
  11. _this[config.method]();
  12. }
  13. };
  14. (0, _event.on)(document, config.event, config.handler);
  15. },
  16. beforeDestroy: function beforeDestroy() {
  17. (0, _event.off)(document, config.event, config.handler);
  18. }
  19. };
  20. };
  21. exports.ClickOutsideMixin = ClickOutsideMixin;