cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/segment-js/1.0.3/segment.min.js"></script>
<script type="text/javascript" src="https://d3js.org/d3-ease.v0.6.min.js"></script>

<button class="refresh-icon">
    <svg viewBox="0 0 90 90">
        <path class="circle-path" d="M 45 45 m 0 -30 a 30 30 0 1 1 0 60 a 30 30 0 1 1 0 -60"></path>
    </svg>
    <svg class="arrow-svg" viewBox="0 0 90 90">
        <path class="arrow-path" d="M 50 15 m -18 -18 l 18 18 l -18 18"></path>
    </svg>
</button>
            
          
!
            
              @import url("https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.min.css");

/* Styles */

html, body {
    height: 100%;
}

body {
    background-color: #2482B4;
}

.refresh-icon {
    position: relative;
    top: 50%;
    left: 50%;
    border: none;
    outline: none;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    width: 100px;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    -webkit-transition: 0.2s background;
    transition: 0.2s background;
}
.refresh-icon:hover {
    background-color: rgba(255, 255, 255, 0.15);
}
.refresh-icon:focus {
    background-color: rgba(255, 255, 255, 0.15);
}
.refresh-icon svg path {
    stroke: #fff;
    stroke-width: 5px;
    stroke-linecap: round;
    fill: none;
}
.refresh-icon svg.arrow-svg {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    -webkit-transform: rotate(-40deg);
    transform: rotate(-40deg);
    -webkit-transform-origin: 50% 50%;
    transform-origin: 50% 50%;
}

.arrow-animation {
    -webkit-animation-name: rotation;
    animation-name: rotation;
    -webkit-animation-duration: 0.8s;
    animation-duration: 0.8s;
    -webkit-animation-timing-function: linear;
    animation-timing-function: linear;
    -webkit-animation-fill-mode: both;
    animation-fill-mode: both;
}

@-webkit-keyframes rotation {
    from {
        -webkit-transform: rotate(-40deg);
        transform: rotate(-40deg);
    }
    80% {
        -webkit-transform: rotate(340deg);
        transform: rotate(340deg);
    }
    99.999% {
        -webkit-transform: rotate(460deg);
        transform: rotate(460deg);
    }
    to {
        -webkit-transform: rotate(-40deg);
        transform: rotate(-40deg);
    }
}

@keyframes rotation {
    from {
        -webkit-transform: rotate(-40deg);
        transform: rotate(-40deg);
    }
    80% {
        -webkit-transform: rotate(340deg);
        transform: rotate(340deg);
    }
    99.999% {
        -webkit-transform: rotate(460deg);
        transform: rotate(460deg);
    }
    to {
        -webkit-transform: rotate(-40deg);
        transform: rotate(-40deg);
    }
}

            
          
!
            
              (function(){

    var refreshButton = document.querySelector('.refresh-icon');
    var circlePath = refreshButton.querySelector('.circle-path');
    var arrowPath = refreshButton.querySelector('.arrow-path');
    var arrowSvg = refreshButton.querySelector('.arrow-svg');
    var circleSegment = new Segment(circlePath, '25%', '90%');
    var arrowSegment = new Segment(arrowPath, '25%', '75%');

    var animating = false;
    refreshButton.addEventListener('click', function(){
        if(!animating){
            animating = true;
            triggerAnimation();
        }
    }, false);

    function triggerAnimation(){
        circleSegment.draw('75%', '165%', 0.5, {circular: true, callback: function(){
            circleSegment.draw('10%', '90%', 0.2, {circular: true, callback: function(){
                circleSegment.draw('25%', '90%', 1.5, {circular: true, easing: d3_ease.easeElasticOut.ease, callback: function(){
                }});
            }});
        }});

        arrowSvg.setAttribute('class', 'arrow-svg arrow-animation');

        arrowSegment.draw('50%', '50% + 0.01', 0.8, {callback: function(){
            arrowSegment.draw('25%', '75%', 1.4, {easing: d3_ease.easeElasticOut.ease, callback: function(){
                arrowSvg.setAttribute('class', 'arrow-svg');
                animating = false;
            }});
        }});
    }

})();

            
          
!
999px
Loading ..................

Console