How to use the @material/snackbar/foundation function in @material/snackbar

To help you get started, we’ve selected a few @material/snackbar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pgbross / vue-material-adapter / packages / mcwv-snackbar / mdc-snackbar.js View on Github external
mounted() {
    window.addEventListener('keydown', this.handleKeydownEvent);

    this.foundation = new MDCSnackbarFoundation({
      addClass: className => this.$set(this.classes, className, true),
      removeClass: className => this.$delete(this.classes, className),
      announce: () => this.announce(this.$refs.labelEl),
      notifyOpening: () =>
        this.$emit(MDCSnackbarFoundation.strings.OPENING_EVENT, {}),
      notifyOpened: () => {
        this.$emit(MDCSnackbarFoundation.strings.OPENED_EVENT, {});
        this.$emit('change', true);
        this.$emit('show', {});
      },
      notifyClosing: reason =>
        this.$emit(
          MDCSnackbarFoundation.strings.CLOSING_EVENT,
          reason ? { reason } : {},
        ),
      notifyClosed: reason => {
github pgbross / vue-material-adapter / packages / mcwv-snackbar / snackbar.js View on Github external
this.$emit('change', true);
        this.$emit('show', {});
      },
      notifyClosing: reason => {
        this.$emit(strings.CLOSING_EVENT, reason ? { reason } : {});
        this.$emit('update:reason', reason);
      },
      notifyClosed: reason => {
        this.$emit(strings.CLOSED_EVENT, reason ? { reason } : {});
        this.$emit('change', false);
        this.$emit('hide');
      },
    };

    const { closeOnEscape, timeoutMs } = this;
    this.foundation = new MDCSnackbarFoundation(adapter);
    this.foundation.init();

    if (timeoutMs !== void 0) {
      this.foundation.setTimeoutMs(timeoutMs);
    }

    this.foundation.setCloseOnEscape(closeOnEscape);
  },
  computed: {