Sha256: 48b633b2d1a373e47fba6c09e5f57dc4d7050fa1a8a24ef7421f7c76a416af39

Contents?: true

Size: 892 Bytes

Versions: 4

Compression:

Stored size: 892 Bytes

Contents

import { Turbo } from "@hotwired/turbo-rails";

import { Modal } from "./modal";

export class FrameModal extends Modal {
  constructor(id, src) {
    super(id);
    this.src = src;
  }

  async dismiss() {
    await super.dismiss();

    if (!this.isCurrentLocation) {
      this.debug("skipping dismiss, not current location");
    } else {
      await this.pop("turbo:load", () => window.history.back());
    }

    // no specific close action required, this is turbo's responsibility
  }

  beforeVisit(frame, e) {
    super.beforeVisit(frame, e);

    e.preventDefault();

    frame.dismiss({ animate: false }).then(() => {
      Turbo.visit(e.detail.url);

      this.debug("before-visit-end");
    });
  }

  popstate(frame, e) {
    super.popstate(frame, e);

    // Turbo will restore modal state, but we need to reset the scrim
    frame.scrimOutlet.hide({ animate: false });
  }
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
katalyst-kpop-3.0.0.beta.7 app/javascript/kpop/modals/frame_modal.js
katalyst-kpop-3.0.0.beta.6 app/javascript/kpop/modals/frame_modal.js
katalyst-kpop-3.0.0.beta.5 app/javascript/kpop/modals/frame_modal.js
katalyst-kpop-3.0.0.beta.4 app/javascript/kpop/modals/frame_modal.js