<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>
</template>
</draggable-header-view>
</div>
<script>
Vue.component('draggable-header-view', {
template: '#header-view-template',
data: function () {
return {
dragging: false,
// quadratic bezier control point
c: { x: 160, y: 160 },
// record drag start point
start: { x: 0, y: 0 }
}
},
computed: {
headerPath: function () {
return 'M0,0 L320,0 320,160' +
'Q' + this.c.x + ',' + this.c.y +
' 0,160'
},
contentPosition: function () {
var dy = this.c.y - 160
var dampen = dy > 0 ? 2 : 4
return {
transform: 'translate3d(0,' + dy / dampen + 'px,0)'