• Loading


    主体实现:

     /*
         loading UI
         */
    
        var Loading = function () {
            this._initId()
                ._init()
                ._createLoading()
                ._initMember();
        }
    
        Loading.prototype = {
            _init: function () {
                this._element = document.createElement('div');
                this._element.classList.add('ui-loading');
                this._element.id = this._loadingId;
                return this;
            },
            _initId: function () {
                this.__uuId = ++uuid;
                this._loadingId = "ui-loading-" + this.__uuId;
                return this;
            },
            _initMember: function () {
                return this;
            },
            _createLoading: function () {
                var backDrop = this._createBackDrop();
                var animation = this._createLoadingAnimation();
                $(this._element).append(backDrop);
                $(this._element).append(animation);
                return this;
            },
            _createBackDrop: function () {
                var fragement = [], h = -1;
                fragement[++h] = "<div class="ui-backdrop"></div>";
                return fragement.join('');
            },
            _createLoadingAnimation: function () {
                var fragement = [], h = -1;
                fragement[++h] = "<div class="ui-loading-dialog">";
                fragement[++h] = "<div class="ui-loading-circle">";
                fragement[++h] = "<span class="left">";
                fragement[++h] = "<span class="anim"></span>";
                fragement[++h] = "</span>";
                fragement[++h] = "<span class="right">";
                fragement[++h] = "<span class="anim"></span>";
                fragement[++h] = "</span>";
                fragement[++h] = "<span class="center"></span>";
                fragement[++h] = "</div>";
                fragement[++h] = "</div>";
                return fragement.join('');
            },
            loading: function (isShow) {
                var self = this;
                var clr = {
                    true: function () {
                        $('body').append(self._element);
                    },
                    false: function () {
                        self._element.remove();
                    },
                    undefined: function () {
                        throw new Error('arguments can not empty.')
                    }
                }
                clr[isShow]();
            }
        }
    
        if (!loader) {
            var loader = new Loading();
        }
        $$.loading = function (isShow) {
            loader.loading(isShow);
        }
    View Code

    样式:

    section {
        border-bottom: 1px solid #FF9900;
        padding: 5px;
    }
    
    /*
        icon
    */
    .ui-dorpdown-icon {
        height: auto;
        width: 20px;
    
        &:after {
            content: '25BC'
        }
    }
    
    /*
        dialog 
    */
    button {
        border: 1px solid #9D9D9D;
        background-color: #fff;
        height: auto;
        padding: 5px 20px;
        border-radius: 5px;
        color: #9D9D9D;
        font-weight: inherit;
        font-style: inherit;
        font-family: inherit;
        cursor: pointer;
    
        &:hover {
            background: #9D9D9D;
            color: #fff;
        }
    }
    
    .ui-backdrop {
        POSITION: fixed;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(34, 34, 34, 0.5);
        z-index: 99;
    }
    
    .dialog {
        position: fixed;
        z-index: 100;
        top: 50%;
        left: 50%;
        right: 0;
        bottom: 0;
        border: 1px solid #ff9900;
        border-radius: 5px;
        text-align: center;
        background: #ffffff;
    
        .dialog-title {
            width: auto;
            height: 40px;
            line-height: 40px;
            background-color: #ff9900;
            font-weight: bold;
            color: #ffffff;
        }
    
        .dialog-content {
            padding: 10px;
        }
    
        .dialog-footer {
            position: absolute;
            bottom: 0px;
            background-color: #ff9900;
            width: 100%;
            height: auto;
            padding: 2px 0;
        }
    }
    
    /* 
        banner 
    */
    .banner {
        position: relative;
        width: 100%;
        height: 400px;
    
        .banner-indicators {
            position: absolute;
            bottom: 20px;
            z-index: 10;
            width: 60%;
            padding-left: 0;
            list-style: none;
            text-align: center;
            width: 25%;
            left: 42%;
    
            .banner-indicators-item {
                list-style: none;
                float: left;
                width: 50px;
                padding: 5px 0;
                margin: 0 2px;
                opacity: 0.5;
                border: 0;
                background-color: #fff;
                height: auto;
                border-radius: 5px;
                margin-right: 50px;
                cursor: pointer;
            }
    
            .active {
                background-image: -webkit-linear-gradient(left, #9D9D9D, #000000 25%, #4F4F4F 50%, #000000 75%, #9D9D9D 100%);
                -webkit-text-fill-color: transparent;
                -webkit-animation: indicators-animation 2s infinite linear;
            }
    
            @-webkit-keyframes indicators-animation {
                0% {
                    background: #9D9D9D;
                    border: 3px solid #ffffff;
                }
    
                50% {
                    background: #000000;
                    border: 3px solid #9D9D9D;
                }
    
                100% {
                    background: #9D9D9D;
                    border: 3px solid #ffffff;
                }
            }
        }
    
        .banner-inner {
            width: 100%;
            height: 100%;
            overflow: hidden;
    
            .banner-content {
                width: 300%;
                height: 100%;
                transform: translate3d(-66.66666666%, 0, 0);
                transition: transform 0.6s ease-in-out;
                -webkit-transition: -webkit-transform 0.6s ease-in-out;
    
                .banner-item {
                    display: inline-block;
                    position: relative;
                    width: 33.333333333%;
                    height: 100%;
                    background-repeat: no-repeat;
                    background-size: cover;
    
                    &:nth-child(1) {
                        background-image: url('./Image/banner0.jpg');
                    }
    
                    &:nth-child(2) {
                        background-image: url('./Image/banner1.jpg');
                    }
    
                    &:nth-child(3) {
                        background-image: url('./Image/banner2.jpg');
                    }
    
                    .banner-item-inner {
                        .title {
                            visibility: hidden;
                            transform: translate3d(-15%, 350%, 0);
                            transition: transform 0.3s ease-in-out;
                            -webkit-transition: -webkit-transform 0.3s ease-in-out;
                        }
    
                        .description {
                            visibility: hidden;
                            transform: translate3d(100%, 300%, 0);
                            transition: transform 0.3s ease-in-out;
                            -webkit-transition: -webkit-transform 0.3s ease-in-out;
                        }
                    }
    
                    .active {
                        .title {
                            visibility: visible;
                            transform: translate3d(30%, 350%, 0);
                        }
    
                        .description {
                            visibility: visible;
                            transform: translate3d(60%, 300%, 0);
                        }
                    }
    
                    .banner-item-inner {
                        p {
                            font-size: 40px;
                            font-weight: bold;
                            color: #fff;
                            font-style: italic;
                        }
                    }
                }
            }
        }
    }
    
    .ui-combobox {
        position: relative;
        width: 200px;
        min-width: 50px;
        height: 30px;
        line-height: 30px;
        background-color: #fff;
        border: 1px solid #bbb;
        outline: 0;
        -moz-box-sizing: border-box;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
    
        .ui-combobox-input {
            position: absolute;
            width: 100%;
            height: 100%;
            margin: 0 auto;
            outline: 0;
            overflow: hidden;
            resize: none;
            border: none;
            background: #fff;
            cursor: default;
            padding: 1px 30px 1px 5px;
            -moz-box-sizing: border-box;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
        }
    
        .ui-combobox-dropdown-container {
            position: absolute;
            height: 100%;
            right: 0;
            top: 0;
            border-left: 1px solid transparent;
            cursor: default;
        }
    
        .ui-combobox-placeholder {
            position: absolute;
            display: table;
            table-layout: fixed;
            height: 100%;
            top: 0;
            left: 5px;
            -moz-box-sizing: border-box;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            color: #aaa;
        }
    }
    
    .ui-combobox-focused {
        border-color: #49d;
    }
    
    .ui-combobox-mouseover {
        border-color: #49d;
    }
    
    .ui-combobox-popup-shown {
        border-color: #49d;
    }
    
    .ui-combobox-popup {
        position: absolute;
        width: 198px;
        height: auto;
        background-color: #ffffff;
        border: 1px solid #bbb;
        box-sizing: content-box;
    
        .ui-combobox-listbox {
            height: auto;
            max-height: 300px;
            min-height: 22px;
            list-style: none;
            overflow: auto;
            background-color: #ffffff;
            box-sizing: border-box;
    
            .ui-combobox-listbox-container {
                display: table;
                width: 100%;
    
                .ui-combobox-selection-container {
                    display: table-row;
    
                    &:hover {
                        background-color: #F0F0F0;
                    }
    
                    .ui-combobox-selection {
                        display: table-cell;
                        border: 1px solid #ffffff;
                        outline: 0;
                        white-space: nowrap;
                        padding: 13px 0 13px 5px;
                        line-height: 1px;
                        cursor: default;
                    }
    
                    .ui-combobox-selection-selected {
                        background-color: #bbb;
                    }
                }
            }
        }
    }
    
    /*
        loading
    */
    
    .ui-loading {
        position: fixed;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 99999;
        display: block;
        text-align: center;
    
        &::before {
            content: '';
            height: 100%;
            width: 0;
            vertical-align: middle;
            display: inline-block;
        }
    
        .ui-loading-dialog {
            position: relative;
            vertical-align: middle;
            display: inline-block;
    
            .ui-loading-circle {
                position: relative;
                height: 60px;
                width: 60px;
                border-radius: 50%;
                background-color: #9D9D9D;
    
                &::before {
                    height: 4px;
                    width: 100%;
                    left: 0;
                    top: 28px;
                    z-index: 1;
                    position: absolute;
                    content: "";
                    background: #fff;
                }
    
                &::after {
                    width: 4px;
                    height: 100%;
                    top: 0;
                    right: 28px;
                    position: absolute;
                    content: "";
                    background: #ffffff;
                }
    
                .left {
                    position: absolute;
                    height: 100%;
                    width: 50%;
                    overflow: hidden;
                    left: 0;
                }
    
                .right {
                    position: absolute;
                    overflow: hidden;
                    height: 100%;
                    width: 50%;
                    left: 50%;
                }
    
                .center {
                    position: absolute;
                    top: 6px;
                    left: 6px;
                    height: 48px;
                    width: 48px;
                    background: #fff;
                    border-radius: 50%;
                }
    
                .anim {
                    position: absolute;
                    left: 100%;
                    top: 0;
                    height: 100%;
                    width: 100%;
                    border-radius: 999px;
                    background-color: #ff9900;
                    -webkit-animation: aui-circle-loading-left 2s infinite;
                    animation: aui-circle-loading-left 2s infinite;
                    -webkit-transform-origin: 0 50% 0;
                    transform-origin: 0 50% 0;
                    -webkit-animation-duration: 2s;
                    -webkit-animation-timing-function: linear;
                    animation-duration: 2s;
                    animation-timing-function: linear;
                }
    
    
                .right .anim {
                    -webkit-animation-name: aui-circle-loading-right;
                    animation-name: aui-circle-loading-right;
                }
    
                .left .anim {
                    border-bottom-left-radius: 0;
                    border-top-left-radius: 0;
                }
    
                .right .anim {
                    border-bottom-right-radius: 0;
                    border-top-right-radius: 0;
                    left: -100%;
                    -webkit-transform-origin: 100% 50% 0;
                    transform-origin: 100% 50% 0;
                }
            }
        }
    }
    
    @keyframes aui-circle-loading-left {
        0% {
            transform: rotate(0deg)
        }
    
        25% {
            transform: rotate(0deg)
        }
    
        50% {
            transform: rotate(180deg)
        }
    
        75% {
            transform: rotate(180deg)
        }
    
        100% {
            transform: rotate(360deg)
        }
    }
    
    
    @keyframes aui-circle-loading-right {
        0% {
            transform: rotate(0deg)
        }
    
        25% {
            transform: rotate(180deg)
        }
    
        50% {
            transform: rotate(180deg)
        }
    
        75% {
            transform: rotate(360deg)
        }
    
        100% {
            transform: rotate(360deg)
        }
    }
    View Code

    效果:

  • 相关阅读:
    欧几里得方程 模幂运算 模乘运算 蒙哥马利模乘 素数测试
    HLG 1058workflow解题报告
    poj 3264Balanced Lineup解题报告
    JavaScript之HTMLCollection接口
    随记2(IE下调试Javascript)
    抽象类和接口
    JavaScript之字符串处理函数
    随记1
    多态
    自动内存管理
  • 原文地址:https://www.cnblogs.com/moran1992/p/11073132.html
Copyright © 2020-2023  润新知