cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-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.

            
              <div class="wrapper">
  <div class="test-result">
    <div class="test-result__inner">
      <ul class="test-result__list"></ul>
    </div>
  </div>
</div>
            
          
!
            
              body,html{font-family:'Apple SD Gothic Neo',AppleSDGothicNeo-Regular,'맑은 고딕','Malgun Gothic','돋움',dotum,AppleGothic,sans-serif,'굴림',Gulim,Helvetica;font-size:1em;padding:0;margin:0}
.wrapper{padding:20px}
.test-result__inner{position:relative}
.test-result__spec{display:inline-block}
.test-result__indicator{color:#fff;padding:8px;background-color:#34c574;display:none}
.test-result__indicator.fail{background-color:#c43c4a}
.test-result__inner p {display:inline-block}
            
          
!
            
              ///////////////////////////////////////////////////////
/////////////////// raf-stub Code(s). //////////////////
///////////////////////////////////////////////////////
!function e(t,n,r){function o(i,a){if(!n[i]){if(!t[i]){var s="function"==typeof require&&require;if(!a&&s)return s(i,!0);if(u)return u(i,!0);var c=Error("Cannot find module '"+i+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[i]={exports:{}};t[i][0].call(f.exports,function(e){var n=t[i][1][e];return o(n?n:e)},f,f.exports,e,t,n,r)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<r.length;i++)o(r[i]);return o}({1:[function(e,t){(function(e){(function(){var n,r,o;"undefined"!=typeof performance&&null!==performance&&performance.now?t.exports=function(){return performance.now()}:void 0!==e&&null!==e&&e.hrtime?(t.exports=function(){return(n()-o)/1e6},r=e.hrtime,n=function(){var e;return e=r(),1e9*e[0]+e[1]},o=n()):Date.now?(t.exports=function(){return Date.now()-o},o=Date.now()):(t.exports=function(){return(new Date).getTime()-o},o=(new Date).getTime())}).call(this)}).call(this,e("_process"))},{_process:2}],2:[function(e,t){function n(){throw Error("setTimeout has not been defined")}function r(){throw Error("clearTimeout has not been defined")}function o(e){if(f===setTimeout)return setTimeout(e,0);if((f===n||!f)&&setTimeout)return f=setTimeout,setTimeout(e,0);try{return f(e,0)}catch(t){try{return f.call(null,e,0)}catch(t){return f.call(this,e,0)}}}function u(e){if(l===clearTimeout)return clearTimeout(e);if((l===r||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(e);try{return l(e)}catch(t){try{return l.call(null,e)}catch(t){return l.call(this,e)}}}function i(){g&&d&&(g=!1,d.length?h=d.concat(h):p=-1,h.length&&a())}function a(){if(!g){var e=o(i);g=!0;for(var t=h.length;t;){for(d=h,h=[];++p<t;)d&&d[p].run();p=-1,t=h.length}d=null,g=!1,u(e)}}function s(e,t){this.fun=e,this.array=t}function c(){}var f,l,m=t.exports={};!function(){try{f="function"==typeof setTimeout?setTimeout:n}catch(e){f=n}try{l="function"==typeof clearTimeout?clearTimeout:r}catch(e){l=r}}();var d,h=[],g=!1,p=-1;m.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];h.push(new s(e,t)),1!==h.length||g||o(a)},s.prototype.run=function(){this.fun.apply(null,this.array)},m.title="browser",m.browser=!0,m.env={},m.argv=[],m.version="",m.versions={},m.on=c,m.addListener=c,m.once=c,m.off=c,m.removeListener=c,m.removeAllListeners=c,m.emit=c,m.binding=function(){throw Error("process.binding is not supported")},m.cwd=function(){return"/"},m.chdir=function(){throw Error("process.chdir is not supported")},m.umask=function(){return 0}},{}],3:[function(e,t,n){(function(t){"use strict";function r(){function e(e){var n=++f,r=function(r){e(r),t(n)};return c.push({id:n,callback:r}),n}function t(e){var t=c.findIndex(function(t){return t.id===e});-1!==t&&c.splice(t,1)}function n(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a;c.length;)o(1,e)}function r(){c.length=0,l=s}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a;if(0!==e){l+=t;var n=c.slice(0);return n.forEach(function(e){e.callback(l)}),o(e-1,t)}}var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u(),c=[],f=0,l=s;return{add:e,remove:t,reset:r,flush:n,step:o}}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.duration,a=void 0===o?i:o,s=n.startTime,c=void 0===s?u():s;arguments.length&&!Array.isArray(e)&&(console.warn("replaceRaf(roots) has been depreciated. Please now use replaceRaf([roots], options). See here for more details: https://github.com/alexreardon/raf-stub/releases"),e=Array.from(arguments)),e.length||e.push("undefined"!=typeof window?window:t);var f=r(a,c);e.forEach(function(e){e.requestAnimationFrame=f.add,Object.assign(e.requestAnimationFrame,{step:f.step,flush:f.flush,reset:f.reset}),e.cancelAnimationFrame=f.remove})}Object.defineProperty(n,"__esModule",{value:!0}),n.default=r,n.replaceRaf=o;var u=e("performance-now"),i=1e3/60}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"performance-now":1}],4:[function(e){"use strict";function t(e){return e&&e.__esModule?e:{"default":e}}var n=e("raf-stub"),r=t(n);window.createStub=r.default},{"raf-stub":3}]},{},[4]);

///////////////////////////////////////////////////////
/////////////////// Product Code(s). //////////////////
///////////////////////////////////////////////////////

function linear(n) {
    return n;
}

class Stepper {
  start(options) {
    const {
      duration = 0,
      easing = linear,
      step = () => {}
    } = options;
    
    let startTime = 0;
    
    const stepping = (timestamp) => {
      if (!startTime) {
        startTime = timestamp;
      }

      const pastTime = timestamp - startTime;
      const progress = pastTime / duration;

      if (pastTime >= duration) {
        step(1);
        return;
      }

      step(easing(progress));
      
      window.requestAnimationFrame(stepping);
    };

    window.requestAnimationFrame(stepping);
  }
}

///////////////////////////////////////////////////////
/////////////// Assert and Test runner ////////////////
///////////////////////////////////////////////////////
const testList = document.querySelector('.test-result__list');

function assert(element, result, text) {
  const indicator = element.querySelector('.test-result__indicator');
  
  indicator.style.display = 'inline-block';
  indicator.querySelector('span').innerHTML = result ? '성공' : '실패';
  indicator.classList.remove('fail');
  
  if (!result) {
      indicator.classList.add('fail');
  }
}

function test(spec, runner) {
  const item = document.createElement('li');
  
  item.innerHTML = `
    <div class="test-result__spec">
      <span>Test Case: </span>
      <p>${spec}</p>
    </div>
    <div class="test-result__indicator">
      <span></span>
    </div>
  `
 
  testList.insertAdjacentElement('beforeend', item);
  
  runner(assert.bind(null, item));
}


///////////////////////////////////////////////////////
///////////////////// TestCode(s). ////////////////////
///////////////////////////////////////////////////////
const stub = createStub();

sinon.stub(window, 'requestAnimationFrame', stub.add);

test('The user should be able to know the current progress through the Stepper\'s start method.', (assert) => {
  // Given
  const stepper = new Stepper();
  const duration = 300;
  const easing = linear;
  const step = sinon.spy();
  
  // When
  stepper.start({
    duration,
    easing,
    step
  });
  
  stub.step(1, 0);
  stub.step(1, 250);

  // THen
  assert(step.args[1][0].toFixed(2) === linear(250 / 300).toFixed(2));
});

window.requestAnimationFrame.restore();
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console