css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

              <template id="header-view-template" style="display:none">
  <div class="draggable-header-view"
    @mousedown="startDrag" @touchstart="startDrag"
    @mousemove="onDrag" @touchmove="onDrag"
    @mouseup="stopDrag" @touchend="stopDrag" @mouseleave="stopDrag">
    <svg class="bg" width="320" height="560">
      <path :d="headerPath" fill="#3F51B5"></path>
    <div class="header">
      <slot name="header"></slot>
    <div class="content" :style="contentPosition">
      <slot name="content"></slot>

  <template slot="header">
    <h1>Elastic Draggable SVG Header</h1>
    <p>with <a href="https://vuejs.org" target="_blank">Vue.js</a> + <a href="http://dynamicsjs.com" target="_blank">dynamics.js</a></p>
  <template slot="content">
    <p>Note this is just an effect demo - there are of course many additional details if you want to use this in production, e.g. handling responsive sizes, reload threshold and content scrolling. Those are out of scope for this quick little hack. However, the idea is that you can hide them as internal details of a Vue.js component and expose a simple Web-Component-like interface.</p>
       <a href="https://github.com/vuejs/vue/tree/dev/examples/elastic-header" target="_blank">[Source]</a>
              .draggable-header-view {
  background-color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  width: 320px;
  height: 560px;
  overflow: hidden;
  margin: 30px auto;
  position: relative;
  font-family: 'Roboto', Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-weight: 300;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  h1 {
    font-weight: 300;
    font-size: 1.8em;
    margin-top: 0;
  .bg {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
  .header, .content {
    position: relative;
    z-index: 1;
    padding: 30px;
    box-sizing: border-box;   
  .header {
    color: #fff;
    height: 160px;
    a {
      color: #fff;
  .content {
    color: #333;
    line-height: 1.5em;
    a {
      color: #3F51B5;
              document.body.addEventListener('touchmove', e => e.preventDefault())

Vue.component('draggable-header-view', {

  template: '#header-view-template',

  data () {
    return {
      dragging: false,
      // quadratic bezier control point
      c: { x: 160, y: 160 },
      // record drag start point
      start: { x: 0, y: 0 }

  computed: {
    headerPath () {
      return `M0,0 L320,0 320,160 Q${ this.c.x },${ this.c.y } 0,160`
    contentPosition () {
      const dy = this.c.y - 160
      const dampen = dy > 0 ? 2 : 4
      return {
        transform: `translate3d(0,${ dy / dampen }px,0)`

  methods: {
    startDrag (e) {
      e = e.changedTouches ? e.changedTouches[0] : e
      this.dragging = true
      this.start.x = e.pageX
      this.start.y = e.pageY
    onDrag (e) {
      e = e.changedTouches ? e.changedTouches[0] : e
      if (this.dragging) {
        this.c.x = 160 + (e.pageX - this.start.x)
        // dampen vertical drag by a factor
        const dy = e.pageY - this.start.y
        const dampen = dy > 0 ? 1.5 : 4
        this.c.y = 160 + dy / dampen
    stopDrag () {
      if (this.dragging) {
        this.dragging = false
        dynamics.animate(this.c, {
          x: 160,
          y: 160
        }, {
          type: dynamics.spring,
          duration: 700,
          friction: 280

new Vue({ el: 'body' })
🕑 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.
Loading ..................