如何在聚焦模态窗口上获得“心跳”效果?

问题描述 投票:0回答:1

引导程序具有documentation about a "static" modal,在外部单击时不会关闭。如果您尝试在他们的演示中单击它之外的内容,则该动画会带有一点“心跳”(或称呼它)效果,表明它需要引起注意。

但是当我从示例中复制其确切的HTML代码时,它不会执行动画。提琴在这里可用:https://jsfiddle.net/5jhuwgnd/

显然这里缺少某些内容,而且似乎没有记载。而且它不能是HTML属性,因为我有HTML示例...是需要包含的额外的JS插件吗?


(由于Stackoverflow不允许无代码的JS Fiddle链接,在这里是,尽管我认为在这里没有它是很重要的)

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#staticBackdrop">
  Launch static backdrop modal
</button>

<!-- Modal -->
<div class="modal fade" id="staticBackdrop" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="staticBackdropLabel">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Understood</button>
      </div>
    </div>
  </div>
</div>
twitter-bootstrap bootstrap-4 bootstrap-modal
1个回答
1
投票

小提琴缺少创建动画的JavaScript。添加latest javascript有效。

[查看源代码时,modal.js文件将类modal-static添加到模态。

  _triggerBackdropTransition() {
    if (this._config.backdrop === 'static') {
      const hideEventPrevented = $.Event(Event.HIDE_PREVENTED)

      $(this._element).trigger(hideEventPrevented)
      if (hideEventPrevented.defaultPrevented) {
        return
      }

      this._element.classList.add(ClassName.STATIC)

      const modalTransitionDuration = Util.getTransitionDurationFromElement(this._element)

      $(this._element).one(Util.TRANSITION_END, () => {
        this._element.classList.remove(ClassName.STATIC)
      })
        .emulateTransitionEnd(modalTransitionDuration)
      this._element.focus()
    } else {
      this.hide()
    }
  }
© www.soinside.com 2019 - 2024. All rights reserved.