Skip to content

Commit

Permalink
add move transitions to todomvc example
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jul 14, 2016
1 parent 210a3a2 commit c1d8ccb
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
37 changes: 28 additions & 9 deletions examples/todomvc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,25 @@
<meta charset="utf-8">
<title>Vue.js • TodoMVC</title>
<link rel="stylesheet" href="node_modules/todomvc-app-css/index.css">
<style> [v-cloak] { display: none; } </style>
<style>
[v-cloak] {
display: none;
}
.todo-list {
position: relative;
overflow: hidden;
}
.todo {
height: 60px;
}
.todo-move, .todo-enter-active, .todo-leave-active {
transition: all .25s cubic-bezier(.55,0,.1,1);
}
.todo-enter, .todo-leave-active {
opacity: 0;
height: 0;
}
</style>
</head>
<body>
<section class="todoapp">
Expand All @@ -18,13 +36,14 @@ <h1>todos</h1>
</header>
<section class="main" v-show="todos.length" v-cloak>
<input class="toggle-all" type="checkbox" v-model="allDone">
<ul class="todo-list">
<li class="todo"
v-for="todo in filteredTodos"
:class="{completed: todo.completed, editing: todo == editedTodo}">
<ul class="todo-list" is="transition-group" name="todo">
<li v-for="todo in filteredTodos"
class="todo"
:key="todo.id"
:class="{ completed: todo.completed, editing: todo == editedTodo }">
<div class="view">
<input class="toggle" type="checkbox" v-model="todo.completed">
<label @dblclick="editTodo(todo)">{{todo.title}}</label>
<label @dblclick="editTodo(todo)">{{ todo.title }}</label>
<button class="destroy" @click="removeTodo(todo)"></button>
</div>
<input class="edit" type="text"
Expand All @@ -41,9 +60,9 @@ <h1>todos</h1>
<strong>{{ remaining }}</strong> {{ remaining | pluralize }} left
</span>
<ul class="filters">
<li><a href="#/all" :class="{selected: visibility == 'all'}">All</a></li>
<li><a href="#/active" :class="{selected: visibility == 'active'}">Active</a></li>
<li><a href="#/completed" :class="{selected: visibility == 'completed'}">Completed</a></li>
<li><a href="#/all" :class="{ selected: visibility == 'all' }">All</a></li>
<li><a href="#/active" :class="{ selected: visibility == 'active' }">Active</a></li>
<li><a href="#/completed" :class="{ selected: visibility == 'completed' }">Completed</a></li>
</ul>
<button class="clear-completed" @click="removeCompleted" v-show="todos.length > remaining">
Clear completed
Expand Down
6 changes: 5 additions & 1 deletion examples/todomvc/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@
if (!value) {
return;
}
this.todos.push({ title: value, completed: false });
this.todos.push({
id: todoStorage.uid++,
title: value,
completed: false
});
this.newTodo = '';
},

Expand Down
9 changes: 7 additions & 2 deletions examples/todomvc/js/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@

'use strict';

var STORAGE_KEY = 'todos-vuejs';
var STORAGE_KEY = 'todos-vuejs-2.0';

exports.todoStorage = {
fetch: function () {
return JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]');
var todos = JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]');
todos.forEach(function (todo, index) {
todo.id = index
});
exports.todoStorage.uid = todos.length;
return todos;
},
save: function (todos) {
localStorage.setItem(STORAGE_KEY, JSON.stringify(todos));
Expand Down

0 comments on commit c1d8ccb

Please sign in to comment.