スピナー(メッセージ付き)を表示する [1.0.0]

概要

ローディングなどの処理中にクルクルまわるスピナーを表示して
処理中であることを視覚的に伝えるアニメーション。

head内に追記

<script charset="UTF-8" src="spinner.js"></script>

使い方:スピナーを表示する

const S = new Spinner();
S.show(inObj);
inObj.message{string|undefined}
表示するメッセージ
inObj.abort{boolean|callback|undefined}
true で中止処理。
callback で中止処理&コールバック。

使い方:スピナーを閉じる

S.destroy();

デモ

それぞれ5秒後に自動的に閉じられます。


<button type="button" onclick="spinner()">くるくるだけ表示</button>


<button type="button" onclick="spinner({message:'しばらくおまちください'})">文字も表示</button>


<button type="button" onclick="spinner({message:'右上の×ボタンで中止できるよ', abort:() => {})">処理中断機能付き</button>


<button type="button" onclick="spinner({message:'右上の×ボタンで中止できるよ', abort:() => { alert('中止しました'); } })">コールバック</button>