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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

    %h1 Bouncy List
    Go on, add or remove items from the list and behold some sweet css animations

  %input.list-input(type="text" placeholder="Add Todo" value="Take out the Trash")
    - initial_notes = ["Buy Milk", "Get Haircut", "Take Dog for a Walk"]
    - initial_notes.each do |a|
  %a(href="" class="twitter-follow-button" data-show-count="false")Follow @code_dependant
  %script !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);;js.src=p+'://';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');
  margin: 0
  padding: 0
  box-sizing: border-box

    content: " "
    display: table
    content: " "
    display: table
    clear: both
  *zoom: 1

$timing-function: ease-in-out
$duration: 1s
$delayRatio: 0.075s

$bounceLimitKeyframe: 30%
$bounceLimit: 50%

  margin-top: 30px

  background-color: #FFE181
  color: #696969
  font-family: 'Roboto Slab', sans-serif
  font-size: 14px
  font-size: 48px
  color: #927963
  position: relative
  display: inline-block
  margin: 0
  margin-bottom: .5rem
  line-height: 1em
  text-align: center
  margin-bottom: 2.5em
  text-align: center
  padding: 1em
  width: 50%
  @media(max-width: 500px)
    width: 80%
  margin: 10px auto

  float: right
  width: 100%
  @extend .padded
  box-shadow: inset 1px 1px 3px 0px rgba(134, 134, 134, 0.21)
  border: 1px solid #C5C5C5

  list-style: none

  transform: translateY(-100%)
  animation-name: slide-from-top
  animation-timing-function: $timing-function
  transform: translateY(-200%) scaleY(1)
  animation-name: slide-from-top--new
  animation-name: slide-from-bottom--removed
  animation-name: slide-from-bottom
  @extend .padded
  margin-bottom: 0.5em
  background-color: white
  border: 1px solid #C5C5C5
  border-radius: 3px
  backface-visibility: hidden
  box-shadow: 1px 1px 3px 0px rgba(134, 134, 134, 0.21)
  animation-duration: $duration
  animation-fill-mode: forwards
  @for $i from 1 through 30
      animation-delay: $i * $delayRatio
      z-index: $i

    display: none
      display: block

  background-color: white
  transform-origin: 50% 0
  @for $i from 1 through 30
      animation-delay: $i * $delayRatio
      z-index: $i
// keyframe animations
@keyframes slide-from-top
    transform: translateY($bounceLimit)
    transform: translateY(0)

@keyframes slide-from-top--new
    background-color: white

    background-color: #D3EBD3
    background-color: #D3EBD3
    transform: translateY($bounceLimit) scaleY(1)
    background-color: white
    transform: translateY(0)
@keyframes slide-from-bottom
    transform: translateY(0)
    transform: translateY(-115%)
@keyframes slide-from-bottom--removed
    transform: translateY(0)
    transform: translateY(-115%)
    opacity: 0

  z-index: -1 !important
  position: absolute

  position: absolute
  bottom: 12px
  left: 20px

  cursor: pointer
  float: right
  min-width: 16px
  min-height: 16px
  opacity: 0.5
              # no jQuery, just for "fun". It was no fun at all.

prefix = (->
  styles = window.getComputedStyle(document.documentElement, "")
  pre = ("").match(/-(moz|webkit|ms)-/) or (styles.OLink is "" and [
  dom = ("WebKit|Moz|MS|O").match(new RegExp("(" + pre + ")", "i"))[1]
  dom: dom
  lowercase: pre
  css: "-" + pre + "-"
  js: pre[0].toUpperCase() + pre.substr(1)

animationEndEvent = prefix.lowercase+"AnimationEnd"
animationEndEvent = "animationend" if prefix.lowercase is "moz"
console.log animationEndEvent

window.insertAnimation = (text, list)->
  items = list.querySelectorAll(".list__item")
  for item in list.querySelectorAll(".list__item")
    item.addEventListener animationEndEvent, (event)->"list__item--inserting")
  newItem = document.createElement("li")
  newItem.classList.add "list__item" 
  newItem.classList.add "list__item--inserting-new"
  newItem.innerHTML = text
  closeIcon = document.createElement("i")
  closeIcon.classList.add "icon-close"
  newItem.appendChild closeIcon
  closeIcon.addEventListener "click", itemClickHandler  

  firstItem = items[0]
  list.insertBefore(newItem, firstItem)
  newItem.addEventListener animationEndEvent, (event)->"list__item--inserting-new")
window.removeAnimation = (index, list)->
  items = list.querySelectorAll(".list__item")
  item = items.item(index)  
  postItems = document.querySelectorAll(".list__item:nth-child(1n+#{(index+2)})")

  postCount = 0
  handler = (event)-> animationEndEvent, arguments.callee
    if postCount is postItems.length or postCount > 5
      for removeItem in postItems
  for postItem in postItems
    postItem.addEventListener animationEndEvent, handler
  if postItems.length is 0
    item.addEventListener animationEndEvent, -> list.removeChild(item)
addListItem = ->
  input = document.querySelectorAll(".list-input").item(0)
  list = document.querySelectorAll(".list").item(0)
  todoText = input.value
  input.value = ""
  if todoText isnt ""
    insertAnimation(todoText, list)

removeListItem = (index)->
  list = document.querySelectorAll(".list").item(0)
  removeAnimation(index, list)
input = document.querySelectorAll(".list-input")[0]

input.addEventListener "keyup", (event)->
  if event.keyCode is 13

itemClickHandler = (event)->
  listItem = "click", arguments.callee
  itemsNodeList = document.querySelectorAll(".list .list__item")
  itemsArray =
  index = itemsArray.indexOf(listItem)
for item in document.querySelectorAll(".list .list__item .icon-close")
  item.addEventListener "click", itemClickHandler = String(input.offsetHeight)+"px"

setTimeout ->
, 1000

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.