[Mac]容量を減らす
DIコンテナはじめ
freee SDKを Laravel で使ってみる
freee API を使ってみる
Segueを利用しない画面遷移
Xcode11.3 で XVim2 を利用する
Codable で JSONを読み込み
Webpack入門
MacからLaradock PostgreSQLで接続エラー
Mac で Laradock の構築
Dockerで不要なイメージを削除
yarn インストール&プロジェクト作成
Laravel 6.x 構築(Homestead編)
Composer インストール
nvm インストール
npm install が Mac でエラー
HTMLタグでカーソルが同時処理(ミラーリング)されてしまう
DI(依存性注入)
[Ubuntu]Let's Encryptで無料の証明書を利用する
[Apache]Apache2.4のアクセス制限が変更
[Ubuntu]rootのログインとsudo権限追加
タミヤ マイコンロボット工作セットをMacに接続してみた
pgAdimn4 でブラウザで開けなくなる
Java8 を HomebrewとjEnvで構築
Android Studio環境構築 2019
ロケールの再構築
vagrant グループに Apacheを追加
Linux2 Apache2 + PHP7.3 + PostgreSQL10
Anadondaの削除
[Mac]初期設定メモ(CentOS)
[Mac]PostgreSQL起動
FormRequest を利用したバリデーション
try-catch で Exception検知
[Debian]Node.js安定板インストール
Middlewareを利用したルートグループ化
namespaceを利用したルートグループ化
名前付きルートによるリダイレクト
artisanコマンド
IE11以下でclosest() を利用する
Karma と Mochaインストール
コンポーネントを親に登録
[脱jQuery]LoadingOverlay をネイティブで実装
Targetを利用せずに新規ウィンドウを開く(rel,class)
[脱jQuery]ネイティブでDrag&Dropやtableソート
[脱jQuery]$(document).on() をネイティブでコーディング
[Git].gitignore が反映されない
[Git]不要ファイル履歴削除
[GAS]Gmail指定ラベルの不要メール削除
UFJ API(開発用)を利用してみる
RuntimeException No application encryption key has been specified
2019/07/02
icon [脱jQuery]LoadingOverlay をネイティブで実装
「jQuery LoadingOverlay」をネイティブで実装してみる。

サンプル

Github: yoo16/html_samples

HTML


  
  
  
  
  

  
This is loading1 element areas.
This is loading1 element areas.
This is loading1 element areas.
This is loading1 element areas.
This is loading1 element areas.
This is loading1 element areas.
This is loading2 element areas.
This is loading2 element areas.
This is loading2 element areas.
This is loading2 element areas.
This is loading2 element areas.
This is loading2 element areas.

Javascript


var LoadingOverlay = function() {
    var _this = this
    this.loading_overlay_name = 'loading_overlay';
    
    this.show = function(selector, options) {
        _this.hide(selector);
        var style = "";
        style+= "position: absolute;";
        style+= "z-index: 1050;";
        style+= "background-color: rgba(255, 255, 255, 0.2);";
        style+= "background-position: center center;";
        style+= "background-repeat: no-repeat;";

        var top = "0;";
        var left = "0;";
        var width = "100%;";
        var height = "100%;";
        var background_size = 'contains';
        var element = document.body;
        if (selector) {
            element = document.getElementById(selector);
            var rect = element.getBoundingClientRect();
            top = rect.top;
            left = rect.left;
            width = element.clientWidth;
            height = element.clientHeight;
            background_size = _this.backgroundSize(element);

            let td = element.closest('td');
            if (td) {
                top = 0;
                left = 0;
            }
        }
        style+= "background-size: " + background_size + ";";
        style+= "top: " + top + "px;";
        style+= "left: " + left + "px;";
        style+= "width: " + width + "px;";
        style+= "height: " + height + "px;";
        style+="background-image: url(" + loading_image + ");";

        _this.loading_overlay_element = document.createElement('div');
        _this.loading_overlay_element.classList.add(_this.loading_overlay_name);
        _this.loading_overlay_element.style = style;

        element.appendChild(_this.loading_overlay_element);

        //timer
        function hideHandler() {
            clearInterval(_this.timer);
            _this.timer = null;
            _this.hide(selector);
        }
        if (options && options.timeout > 0) {
            if (!_this.timer) _this.timer = setInterval(hideHandler, options.timeout);
        }
    }
    this.hide = function(selector) {
        var parent_element;
        if (selector) {
            parent_element = document.getElementById(selector);
        } else {
            parent_element = document.body;
        }
        [].forEach.call(parent_element.children, function(element) {
            if (element.classList.contains(_this.loading_overlay_name)) {
                parent_element.removeChild(element);
            }
        });
    }
    this.backgroundSize = function(element) {
        background_size = "contains";
        var img = new Image();
        img.src = loading_image;

        var width_rate = 0;
        var height_rate = 0;
        if (img.width > element.clientWidth) {
            width_rate = element.clientWidth / img.width;
        }
        if (img.height > element.clientHeight) {
            height_rate = element.clientHeight / img.height;
        }
        var rate = 0;
        if (width_rate > height_rate) {
            rate = width_rate;
        } else {
            rate = height_rate;
        }
        if (rate > 0) background_size = rate * 30 + "%;"
        return background_size;
    }
}
var loading_image = "data:image/gif;base64,R0lGODlhZABkAKUAADQyNJyanGRmZMzOzExOTLS2tISChOzq7ERCRKyqrHR2dNze3FxaXMTCxIyOjPT29Dw6PKSipGxubNTW1FRWVLy+vIyKjPTy9ExKTLSytHx+fOTm5GRiZMzKzJSWlPz+/DQ2NJyenGxqbNTS1FRSVLy6vISGhOzu7ERGRKyurHx6fOTi5FxeXMTGxJSSlPz6/Dw+PKSmpHRydNza3P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJBQA0ACwAAAAAZABkAAAG/kCacEgsGo/IJO1SEEBAosJFSa1ar9jswQQBeAEgyyFLLpvNL893DXC9zvC4XDggsb+EwXzPtyZAd14gCX2FhkQRgIEAIYeOSAMWIgoxY1UpioEpj5xCFx6ZACQVH1QjFIt5nY8PIV1sKCtUaYsOpVcfb6tWM6iBJlUnJqEAJidYKxYaFbq7SSXEXxQPVQ8VEjBQFVNXDypeKCPOSR8ZiwAox50rLF8Z40kV0V7Tqw8WXgQT8EgzDIvAdm1I4WFAM35EPqSAcYeAul25ECZ5EYPAGgH7JGo08mFACAcOChy4tbHkkA8PDppcybKly5cwY8rc8+HEiBYDRs509qKF/goCCAhIaEBy56MBFtcQaGCU04ukbFgsaErlQAQFETZgGbAIRAmqEx0oskDNirlFMcAieWDHCwtZVkqce6fWyAMBXyQ8pHKCYcOMdROOEIBBQIssAQI5KBs44YEWcLGcELvGWONCHyZ40OBhQtHLoEOLHk26tOnTqFOrXs26tevXEj+0MCFDBTPYSi64QPAFhgFLrl8c2HCC5IsUvNeAiMB49YsCFBCwICrkgIRABICvboEBz1QaC7oHmuEa1JdBQhZAZfOdtXlBdE8oCERBa+tTX94KeZ58TYjPqfWkAAsaiDPEcX6B4UFzrV1wAoNCbBCCCSG0h9uFGGao4YYc/nbo4YcghijiiCW9sMEMG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5ywwAoIZvhBAjKwIIADM+DywAAVYDrRCwEkhwYLfjHywQgiIIAACi5kKo0zrShg6xjafBICn4t84AIvEDR6hSqtUHDkNy+YkMyybHzg5icoRPmNB09aY+wQb1ywq2FpfRLmQiMQCYkDZ8COskACBpiQwArp0rCAuQB4wJAsdAKggKBIzKAmNyLwe8QLDbylwYMLceGAABKkcEK8SqIxnhOhVVDABAhLdkC+ymzL2QwcWwNthReU2Uu8nE3rSXUZ9vElCkxyOGoMMQzg8aRtBAEAOw==";

var loading_overlay = new LoadingOverlay();

表示処理

document.createElement('div') で LoadingOver Element を作成し、style を動的に設定後、ターゲットに追加(appendChild()) している。 (ターゲットがない場合は document.body) styleはターゲットの位置やサイズを取得して absolute で位置合わせしている。 ローディング画像(loading_image)は、画像をBase64に変換しているが、URLでも構わない。 backgroundSize() ではローディング画像のサイズを調整している。 ローディング画像が親より小さければ「background_size: contains」、大きければ「%」で調整する。

非表示処理

指定したIDの子要素の中の、LoadingOver Element のクラスを検索して削除(removeChild()) これで要素毎のローディングにも対応できる。