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 Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

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.

            
              <ul>
  <li>
    <h2>Iteration Composite: Replace (Default)</h2>
    <div id="animated-icr"></div>
    <p id="info-icr"><span>Verifying...</span><span>Expecting <code>filter: blur(1px)</code></span><span class="actual">Actual <code>...</code></span></p>
  </li>
  <li>
    <h2>Iteration Composite: Accumulate</h2>
    <div id="animated-ic"></div>
    <p id="info-ic"><span>Verifying...</span><span>Expecting <code>filter: blur(2px)</code></span><span class="actual">Actual <code>...</code></span></p>
  </li>
  <li>
    <h2>Animation Composite: Add</h2>
    <div id="animated-ca"></div>
    <p id="info-ca"><span>Verifying...</span><span>Expecting <code>filter: blur(2px) opacity(0.5)</code></span><span class="actual">Actual <code>...</code></span></p>
  </li>
  <li>
    <h2>Animation Composite: Accumulate</h2>
    <div id="animated-c"></div>
    <p id="info-c"><span>Verifying...</span><span>Expecting <code>filter: blur(5px)</code></span><span class="actual">Actual <code>...</code></span></p>
  </li>
</ul>
            
          
!
            
              div {
  border: 2vmin solid #fff;
  width: 10vmin;
  height: 10vmin;
  position:relative;
  
  &::before, &::after {
    border: 2vmin solid #fff;
    margin-top: 0vmin;
    width: 8vmin;
    height: 8vmin;
    display: inline-block;
    content: '';
    position: absolute;
    left: -12vmin;
    top: -1vmin;
  }
  &::after {
    left: initial;
    right: -12vmin;
    
  }
}
body {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  min-height: 100vh;
  background: #384664;//#d43846;
  color: #fdfdff;
  font-family: -apple-system, 'Segoe UI', 'Helvetica Neue', sans-serif;
}
ul {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
li {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  min-height: calc(10vmin + 12rem);
  padding: 1rem 0;
  
  &:not(:last-of-type) {
    border-bottom: 1px solid #333;
  }
}
p {
  background: #fdfdff;
  padding: .5rem;
  font-weight: bold;
  color: #444;
  text-align: center;
}
p span:not(:first-of-type) {
  font-size: .75rem;
  display: block;
  padding-top: .5rem;
  text-align: right;
}
code {
  font-family: monospace;
}
.correct {
  color: #34b078;
}
.incorrect {
  color: #b03659;
}

*, *::after, *::before {
  box-sizing: border-box;
}
            
          
!
            
              compositeAdd();
compositeAccumulate();
iterationCompositeAccumulate();
iterationCompositeReplace();

function compositeAccumulate() {
  let animated = document.getElementById('animated-c');
  let infoc = document.getElementById('info-c');
  let info = infoc.querySelector('span');

  animated.animate([
    { filter: 'blur(1px)' },
    { filter: 'blur(2px)'}
  ], {
    duration: 500,
    iterations: 1,
    fill: 'forwards',
    direction: 'normal',
    composite: 'replace'
  }).onfinish = (function() {
    animated.animate([
      { filter: 'blur(0px)' },
      { filter: 'blur(3px)'}
    ], {
      duration: 500,
      iterations: 1,
      fill: 'forwards',
      direction: 'normal',
      composite: 'accumulate'
    }).onfinish = function() {
      var filter = getComputedStyle(animated).filter;
      var blur = parseFloat(filter.substring(5, filter.length - 3));
      console.log(blur);
      if (blur == 5) {
        info.textContent = 'Blur value did accumulate';
        info.classList.add('correct');
      } else {
        info.textContent = 'Blur value did not accumulate';
        info.classList.add('incorrect');
      }
      infoc.querySelector('.actual code').textContent = 'filter: ' + filter;
    }
  });
}
function compositeAdd() {
  let animated = document.getElementById('animated-ca');
  let infoca = document.getElementById('info-ca');
  let info = infoca.querySelector('span');

  animated.animate([
    { filter: 'blur(0px)' },
    { filter: 'blur(2px)'}
  ], {
    duration: 500,
    iterations: 1,
    fill: 'forwards',
    direction: 'normal',
    composite: 'replace'
  }).onfinish = (function() {
    animated.animate([
      { filter: 'opacity(1)' },
      { filter: 'opacity(.5)'}
    ], {
      duration: 500,
      iterations: 1,
      fill: 'forwards',
      direction: 'normal',
      composite: 'add'
    }).onfinish = function() {
      var filter = getComputedStyle(animated).filter;
      var hasBlur = filter.indexOf('blur(') > -1;
      var hasGray = filter.indexOf('opacity(') > -1;
      if (hasBlur && hasGray) {
        info.textContent = 'Filter value did add';
        info.classList.add('correct');
      } else {
        info.textContent = 'Filter value did not add';
        info.classList.add('incorrect');
      }
      infoca.querySelector('.actual code').textContent = 'filter: ' + filter;
    }
  });
}




function iterationCompositeAccumulate() {
  let animatedic = document.getElementById('animated-ic');
  let info = document.getElementById('info-ic');
  let infoic = info.querySelector('span');

  animatedic.animate([
    { filter: 'blur(0)' },
    { filter: 'blur(1px)'}
  ], {
    duration: 500,
    iterations: 2,
    fill: 'both',
    direction: 'normal',
    iterationComposite: 'accumulate'
  }).onfinish = (function() {
    var filter = getComputedStyle(animatedic).filter;
    var blur = parseFloat(filter.substring(5, filter.length - 3));
    if (blur > 1) {
      infoic.textContent = 'Blur value did accumulate';
      infoic.classList.add('correct');
    } else {
      infoic.textContent = 'Blur value did not accumulate';
      infoic.classList.add('incorrect');
    }
    info.querySelector('.actual code').textContent = 'filter: ' + filter;
  });
}
function iterationCompositeReplace() {
  let animatedic = document.getElementById('animated-icr');
  let info = document.getElementById('info-icr')
  let infoic = info.querySelector('span');

  animatedic.animate([
    { filter: 'blur(0)' },
    { filter: 'blur(1px)'}
  ], {
    duration: 500,
    iterations: 2,
    fill: 'both',
    direction: 'normal',
    iterationComposite: 'replace'
  }).onfinish = (function() {
    var filter = getComputedStyle(animatedic).filter;
    var blur = parseFloat(filter.substring(5, filter.length - 3));
    if (blur == 1) {
      infoic.textContent = 'Blur value was replaced';
      infoic.classList.add('correct');
    } else {
      infoic.textContent = 'Blur value was not replaced';
      infoic.classList.add('incorrect');
    }
    info.querySelector('.actual code').textContent = 'filter: ' + filter;
  });
}
            
          
!
999px
Loading ..................

Console