LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code

You are logged in!

Crafted by Ionel Cucu
CSS
/* 
    Have any Dribbble invite?
    Why don't you send me one,
    I'll appreciate it and will thank you.

    https://dribbble.com/cucuionel

    https://github.com/cucuionel
    https://www.behance.net/CucuIonel
    http://www.cucuionel.com

*/


button{
    background:#27ae60;
    border:1px solid #1F8C4D;
    color:#fff;
    padding:20px 70px;
    font-size:24px;
    position:relative;
    outline:none;
    cursor:pointer;
    min-width:300px;
    -webkit-border-radius:3px;
    -moz-border-radius
    border-radius:3px;
    -webkit-transition:background 0.2s ease;
    -moz-transition:background 0.2s ease;
    transition:background 0.2s ease;
    -webkit-box-shadow:0 2px 2px rgba(0,0,0,0.1);
    -moz-box-shadow:0 2px 2px rgba(0,0,0,0.1);
    box-shadow:0 2px 2px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.5);
}
button:not([disabled]):hover{
     background:#2ecc71;
}
button[disabled]{
  background: #3c7d57;
  color: #ffffff3b;
  cursor: default;
}
button:after{
    content:'';
    display:block;
    position:absolute;
    opacity:0;
    width:30px;
    height:30px;
    border:5px solid rgba(255,255,255,0.3);
    border-right-color:#fff;
    -webkit-border-radius:50%;
    -moz-border-radius:50%;
    border-radius:50%;
    left:-30px;
    top:15px;
    
    -webkit-transition-property: -webkit-transform;
    -webkit-transition-duration: 1s;

    -moz-transition-property: -moz-transform;
    -moz-transition-duration: 1s;
    
    -webkit-animation-name: rotate; 
    -webkit-animation-duration: 1s; 
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-timing-function: linear;
    
    -moz-animation-name: rotate; 
    -moz-animation-duration: 1s; 
    -moz-animation-iteration-count: infinite;
    -moz-animation-timing-function: linear;
    
    transition:all 0.2s linear;
    -webkit-transform:scale(2);
    transform:scale(2);
}

button.loading:after {
    opacity:1;
    left:15px;
}

@-webkit-keyframes rotate {
    from {-webkit-transform: rotate(0deg);}
    to {-webkit-transform: rotate(360deg);}
}

@-moz-keyframes rotate {
    from {-moz-transform: rotate(0deg);}
    to {-moz-transform: rotate(360deg);}
}

*{
  -webkit-box-sizing:border-box;
  -moz-box-sizing:border-box;
  box-sizing:border-box;
}

body{
  background:#ededed;
  font-family:Arial, sans-serif;
}

a{
  color:#7f8c8d;
}

.form-container{
  padding: 50px 40px;
  background:#fff;
  width:400px;
  text-align:center;
  -webkit-box-shadow:0 2px 3px rgba(0,0,0,0.2);
  -moz-box-shadow:0 2px 3px rgba(0,0,0,0.2);
  box-shadow:0 2px 3px rgba(0,0,0,0.2);
  margin:0 auto;
  margin-top:100px;
  -webkit-transition:all 1s linear;
  -moz-transition:all 1s linear;
  transition:all 1s linear;
  position:relative;
}

.form-container:after{
  content:"";
  display:block;
  position:absolute;
  top:0;
  left:0;
  width:100px;
  height:10px;
  background:#e74c3c;
  -webkit-box-shadow:100px 0 0 #e67e22, 200px 0 0 #f1c40f, 300px 0 0 #1abc9c;
  -moz-box-shadow:100px 0 0 #e67e22, 200px 0 0 #f1c40f, 300px 0 0 #1abc9c;
  box-shadow:100px 0 0 #e67e22, 200px 0 0 #f1c40f, 300px 0 0 #1abc9c;
}

.done .login-form{
  display:none;
}

.form-container .thank-msg{
  display:none;
}

.done .thank-msg{
  display:block;
}

.form-container h3{
  font-size:32px;
  text-align:center;
  color:#666;
  margin:0 0 30px;
}

.form-container .login-form > div{
  margin-bottom:20px;
}

.form-container .login-form > div > input{
  border:2px solid #dedede;
  padding:20px;
  font-size:20px;
  min-width:300px;
  color:#666;
  -webkit-border-radius:3px;
  -moz-border-radius:3px;
  border-radius:3px;
  outline:none;
  -webkit-transition:border-color 0.2s linear;
  -moz-transition:border-color 0.2s linear;
  transition:border-color 0.2s linear;
}

.form-container .login-form > div > input:focus{
  border-color:#A5A5A5;
}

.credits{
  text-align:center;
  color:#999;
  padding:10px;
}
JS
angular
    .module('App',[])
    .controller('LoginController', ['$scope', function($scope){
        $scope.done = '';
    }])
    .directive('loadingBtn', ['$timeout', function($timeout){
        return {
            link: function(scope, element, attrs){
                element.bind('click', function(){
                  
                  if(scope.loading == true || scope.done == 'done') {
                    return;
                  }

                  scope.loading = true;
                  element.addClass('loading');
                  element.attr('disabled', true);
                  $timeout(loadTheButtonAfterSomeTime, 2000); 

                  function loadTheButtonAfterSomeTime(){
                    scope.loading = false;
                    element.removeClass('loading');
                    element.attr('disabled', null);
                    scope.done = 'done';
                  }
                });
            }
        };
    }]);
Host Instantly Drag and Drop Website Builder

 

Description

Here is an implementation of a button with a loading indicator triggered on click and removed when the action is done. This is achieved using AngularJS. It's a demo.
Term
Wed, 11/29/2017 - 11:25

Related Codes

Pen ID
Pen ID
Pen ID