SVGSVGElement: phương thức unpauseAnimations()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Phương thức unpauseAnimations() của giao diện SVGSVGElement tiếp tục các hoạt hình đang chạy hiện tại được xác định trong mảnh tài liệu SVG, khiến đồng hồ hoạt hình tiếp tục từ thời điểm nó bị tạm dừng.

Cú pháp

js
unpauseAnimations()

Tham số

Không có.

Giá trị trả về

Không có (undefined).

Ví dụ

Tiếp tục hoạt hình

html
<svg id="exampleSVG" width="200" height="100">
  <circle cx="50" cy="50" r="30" fill="blue">
    <animate
      attributeName="cx"
      from="50"
      to="150"
      dur="2s"
      repeatCount="indefinite" />
  </circle>
</svg>

<button id="pauseBtn">Tạm dừng hoạt hình</button>
<button id="resumeBtn">Tiếp tục hoạt hình</button>
<pre id="status"></pre>
js
const svgElement = document.getElementById("exampleSVG");
const pauseButton = document.getElementById("pauseBtn");
const resumeButton = document.getElementById("resumeBtn");
const statusDisplay = document.getElementById("status");

pauseButton.addEventListener("click", () => {
  svgElement.pauseAnimations();
  statusDisplay.textContent = "Animations paused.";
});

resumeButton.addEventListener("click", () => {
  svgElement.unpauseAnimations();
  statusDisplay.textContent = "Animations resumed.";
});

Thông số kỹ thuật

Thông số kỹ thuật
SVG Animations Level 2
# __svg__SVGSVGElement__unpauseAnimations

Tương thích trình duyệt

Xem thêm