• モーダル
  • モーダル内でのシーン切り替えが可能
<div id="example_modal" class="modal_01--container">
  <div class="modal_01 modal_01-no_border">
    <div class="modal_01--frame">
      <div class="modal_01--scenes">
        <div class="modal_01--scene">
          <p>1</p>
          <button class="btn modal_01--next">2へ</button>
        </div>

        <div class="modal_01--scene">
          <p>2</p>
          <button class="btn modal_01--next">3へ</button>
        </div>

        <div class="modal_01--scene">
          <p>3</p>
          <button class="btn modal_01--close">閉じる</button>
        </div>
      </div>
      <div class="modal_01--loading">
        Loading ...
      </div>
    </div>
  </div>
</div>



<div style="text-align:center; margin: 50px 0;">
  <button data-target-modal-id="example_modal" class="btn">Modal Open</button>
</div>
/* No context defined. */
  • Content:
    // =====================================================================================
    //
    // modal_01
    //
    // =====================================================================================
    
    @use 'scss/global' as g;
    
    // -------------------------------------------------------------------------------------
    // 変数
    // -------------------------------------------------------------------------------------
    
    // モーダル本体の最大幅
    $max_width: 800px;
    
    // オーバーレイ背景色
    $bg_color: rgba(0, 0, 0, 0.53);
    
    // 角丸半径
    $border-radius: 4px;
    
    // -------------------------------------------------------------------------------------
    // 全画面枠
    // -------------------------------------------------------------------------------------
    .modal_01--container {
      position: fixed;
      top: 0;
      left: 0;
      z-index: 2147483647;
      display: none;
      width: 100%;
      height: 100%;
      background-color: $bg_color;
    
      &.is_close {
        display: none;
      }
    
      &.is_open {
        display: flex;
      }
    }
    
    // -------------------------------------------------------------------------------------
    // 全画面枠 > モーダル本体
    // -------------------------------------------------------------------------------------
    .modal_01 {
      position: relative;
      width: 100%;
      max-width: $max_width;
      margin: auto;
      background: #fff;
      border-radius: $border-radius;
    }
    
    // -------------------------------------------------------------------------------------
    // 全画面枠 > モーダル本体 > 内枠
    // -------------------------------------------------------------------------------------
    .modal_01--frame {
      border-radius: $border-radius;
    }
    
    // -------------------------------------------------------------------------------------
    // 全画面枠 > モーダル本体 > 内枠 > シーンコンテナ
    // -------------------------------------------------------------------------------------
    .modal_01--scenes {
      border-radius: $border-radius;
    }
    
    // -------------------------------------------------------------------------------------
    // 全画面枠 > モーダル本体 > 内枠 > シーンコンテナ > シーン単体
    // -------------------------------------------------------------------------------------
    .modal_01--scene {
      padding: 40px;
      text-align: center;
      background: #fff;
      border-radius: $border-radius;
    
      &.is_hide {
        display: none;
      }
    
      &.is_show {
        display: block;
      }
    }
    
    // -------------------------------------------------------------------------------------
    // 全画面枠 > モーダル本体 > 内枠 > 読み込み中表示
    // -------------------------------------------------------------------------------------
    .modal_01--loading {
      position: absolute;
      top: 0;
      left: 0;
      display: none;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 100%;
      background: #ffffff;
      border-radius: 7px;
      opacity: 0.8;
    
      &.is_hide {
        display: none;
      }
    
      &.is_show {
        display: flex;
      }
    }
    
    // -------------------------------------------------------------------------------------
    // アニメーション: 開く
    // -------------------------------------------------------------------------------------
    @keyframes modal_01_open {
      from {
        opacity: 0;
      }
      to {
        opacity: 1;
      }
    }
    
    @keyframes modal_01_open_box {
      from {
        opacity: 0;
        transform: scale(0.9);
      }
      to {
        opacity: 1;
        transform: scale(1);
      }
    }
    
    .modal_01-open_anim {
      display: flex;
      animation: modal_01_open 0.3s g.$ease_out_cubic;
    
      .modal_01 {
        animation: modal_01_open_box 0.3s g.$ease_out_cubic;
      }
    }
    
    // -------------------------------------------------------------------------------------
    // アニメーション: 閉じる
    // -------------------------------------------------------------------------------------
    @keyframes modal_01_close {
      from {
        opacity: 1;
      }
      to {
        opacity: 0;
      }
    }
    
    @keyframes modal_01_close_box {
      from {
        opacity: 1;
        transform: scale(1);
      }
      to {
        opacity: 0;
        transform: scale(0.9);
      }
    }
    
    .modal_01-close_anim {
      display: flex;
      animation: modal_01_close 0.2s g.$ease_out_cubic;
    
      .modal_01 {
        animation: modal_01_close_box 0.2s g.$ease_out_cubic;
      }
    }
    
    // -------------------------------------------------------------------------------------
    // アニメーション: シーン切り替え
    // -------------------------------------------------------------------------------------
    @keyframes modal_01_transition_scene {
      from {
        opacity: 0;
      }
      to {
        opacity: 1;
      }
    }
    
    .modal_01-transition_scene_anim {
      display: block;
      animation: modal_01_transition_scene 0.5s g.$ease_out_cubic;
    }
    
  • URL: /components/raw/modal_01/_modal_01.scss
  • Filesystem Path: src/assets/_parts/components/modal/modal_01/_modal_01.scss
  • Size: 4.6 KB
  • Content:
    // =====================================================================================
    //
    // modal_01
    //  - このファイルを「src/js/components」に移動の上、呼び出してください
    //    - JSわかる人は「src/js/classes/Modal.js」を直接使ったほうが色々できます
    //  - 呼び出しの際、第一引数でRootsを、第二引数でモーダル要素に付与したIDを指定してください
    //  - 記述例:
    //      import modal_01 from './components/modal_01';
    //      modal_01('modal_01', 'example_modal');
    //
    // =====================================================================================
    
    import $ from 'jquery';
    import Modal from '@/js/classes/Modal';
    
    export default function (rootsName, modalId) {
      $(() => {
        const modal = new Modal(modalId, rootsName);
        $('[data-target-modal-id=' + modalId + ']').each((index, element) => {
          $(element).on('click', () => {
            modal.open();
          });
        });
      });
    }
    
  • URL: /components/raw/modal_01/modal_01.js
  • Filesystem Path: src/assets/_parts/components/modal/modal_01/modal_01.js
  • Size: 977 Bytes