Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
todomvc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
todomvc
Commits
c1075787
Commit
c1075787
authored
Jun 06, 2016
by
Tim Branyen
Committed by
Sam Saccone
Jul 23, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use transpiler and inline transitions
parent
c00e3c4d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
17 deletions
+25
-17
examples/diffhtml/lib/components/todo-app.js
examples/diffhtml/lib/components/todo-app.js
+21
-14
examples/diffhtml/package.json
examples/diffhtml/package.json
+4
-3
No files found.
examples/diffhtml/lib/components/todo-app.js
View file @
c1075787
import
*
as
diff
from
'
diffhtml
'
;
import
*
as
diff
from
'
diffhtml
'
;
import
inlineTransitions
from
'
diffhtml-inline-transitions
'
;
import
store
from
'
../redux/store
'
;
import
store
from
'
../redux/store
'
;
import
*
as
todoAppActions
from
'
../redux/actions/todo-app
'
;
import
*
as
todoAppActions
from
'
../redux/actions/todo-app
'
;
import
renderTodoList
from
'
./todo-list
'
;
import
renderTodoList
from
'
./todo-list
'
;
const
{
html
,
innerHTML
,
addTransitionState
}
=
diff
;
const
{
html
,
innerHTML
}
=
diff
;
// Used to silence errors produced by missing Web Animations API support in the
// Used to silence errors produced by missing Web Animations API support in the
// transition promises below.
// transition promises below.
const
warnAboutWebAnim
=
()
=>
console
.
info
(
'
No Web Animations API support
'
);
const
warnAboutWebAnim
=
()
=>
console
.
info
(
'
No Web Animations API support
'
);
// Allow diffHTML transitions to be bound inside the tagged helper.
inlineTransitions
(
diff
);
export
default
class
TodoApp
{
export
default
class
TodoApp
{
static
create
(
mount
)
{
return
new
TodoApp
(
mount
);
}
static
create
(
mount
)
{
return
new
TodoApp
(
mount
);
}
constructor
(
mount
)
{
constructor
(
mount
)
{
addTransitionState
(
'
attached
'
,
this
.
animateAttached
);
addTransitionState
(
'
detached
'
,
this
.
animateDetached
);
this
.
mount
=
mount
;
this
.
mount
=
mount
;
this
.
existing
Markup
=
this
.
mount
.
innerHTML
;
this
.
existing
Footer
=
this
.
mount
.
querySelector
(
'
footer
'
).
cloneNode
(
true
)
;
this
.
unsubscribeStore
=
store
.
subscribe
(()
=>
this
.
render
());
this
.
unsubscribeStore
=
store
.
subscribe
(()
=>
this
.
render
());
this
.
render
();
this
.
render
();
}
}
animateAttached
(
element
)
{
animateAttached
(
parent
,
element
)
{
if
(
!
element
.
animate
)
{
return
;
}
if
(
element
.
matches
(
'
footer.info
'
))
{
if
(
element
.
matches
(
'
footer.info
'
))
{
new
Promise
(
resolve
=>
element
.
animate
([
new
Promise
(
resolve
=>
element
.
animate
([
{
opacity
:
0
,
transform
:
'
scale(.5)
'
},
{
opacity
:
0
,
transform
:
'
scale(.5)
'
},
{
opacity
:
1
,
transform
:
'
scale(1)
'
}
{
opacity
:
1
,
transform
:
'
scale(1)
'
}
],
{
duration
:
250
}).
onfinish
=
resolve
).
then
(()
=>
{
],
{
duration
:
250
}).
onfinish
=
resolve
).
then
(()
=>
{
element
.
style
.
opacity
=
1
;
element
.
style
.
opacity
=
1
;
})
.
then
(
null
,
warnAboutWebAnim
)
;
});
}
}
// Animate Todo item being added.
// Animate Todo item being added.
...
@@ -38,7 +41,7 @@ export default class TodoApp {
...
@@ -38,7 +41,7 @@ export default class TodoApp {
new
Promise
(
resolve
=>
element
.
animate
([
new
Promise
(
resolve
=>
element
.
animate
([
{
opacity
:
0
,
transform
:
'
scale(.5)
'
},
{
opacity
:
0
,
transform
:
'
scale(.5)
'
},
{
opacity
:
1
,
transform
:
'
scale(1)
'
}
{
opacity
:
1
,
transform
:
'
scale(1)
'
}
],
{
duration
:
250
}).
onfinish
=
resolve
)
.
then
(
null
,
warnAboutWebAnim
)
;
],
{
duration
:
250
}).
onfinish
=
resolve
);
}
}
// Animate the entire app loading.
// Animate the entire app loading.
...
@@ -46,17 +49,19 @@ export default class TodoApp {
...
@@ -46,17 +49,19 @@ export default class TodoApp {
new
Promise
(
resolve
=>
element
.
animate
([
new
Promise
(
resolve
=>
element
.
animate
([
{
opacity
:
0
,
transform
:
'
translateY(100%)
'
,
easing
:
'
ease-out
'
},
{
opacity
:
0
,
transform
:
'
translateY(100%)
'
,
easing
:
'
ease-out
'
},
{
opacity
:
1
,
transform
:
'
translateY(0)
'
}
{
opacity
:
1
,
transform
:
'
translateY(0)
'
}
],
{
duration
:
375
}).
onfinish
=
resolve
)
.
then
(
null
,
warnAboutWebAnim
)
;
],
{
duration
:
375
}).
onfinish
=
resolve
);
}
}
}
}
animateDetached
(
el
)
{
animateDetached
(
parent
,
element
)
{
if
(
!
element
.
animate
)
{
return
;
}
// We are removing an item from the list.
// We are removing an item from the list.
if
(
el
.
matches
(
'
.todo-list li
'
))
{
if
(
el
ement
.
matches
(
'
.todo-list li
'
))
{
return
new
Promise
(
resolve
=>
el
.
animate
([
return
new
Promise
(
resolve
=>
el
ement
.
animate
([
{
opacity
:
1
,
transform
:
'
scale(1)
'
},
{
opacity
:
1
,
transform
:
'
scale(1)
'
},
{
opacity
:
0
,
transform
:
'
scale(.5)
'
}
{
opacity
:
0
,
transform
:
'
scale(.5)
'
}
],
{
duration
:
250
}).
onfinish
=
resolve
)
.
then
(
null
,
warnAboutWebAnim
)
;
],
{
duration
:
250
}).
onfinish
=
resolve
);
}
}
}
}
...
@@ -198,6 +203,8 @@ export default class TodoApp {
...
@@ -198,6 +203,8 @@ export default class TodoApp {
innerHTML
(
this
.
mount
,
html
`
innerHTML
(
this
.
mount
,
html
`
<section class="todoapp"
<section class="todoapp"
attached=
${
this
.
animateAttached
}
detached=
${
this
.
animateDetached
}
onsubmit=
${
this
.
onSubmitHandler
.
bind
(
this
)}
onsubmit=
${
this
.
onSubmitHandler
.
bind
(
this
)}
onclick=
${
this
.
onClickHandler
.
bind
(
this
)}
onclick=
${
this
.
onClickHandler
.
bind
(
this
)}
onkeydown=
${
this
.
handleKeyDown
.
bind
(
this
)}
onkeydown=
${
this
.
handleKeyDown
.
bind
(
this
)}
...
@@ -260,7 +267,7 @@ export default class TodoApp {
...
@@ -260,7 +267,7 @@ export default class TodoApp {
`
:
''
}
`
:
''
}
</section>
</section>
${
this
.
existing
Markup
}
${
this
.
existing
Footer
}
`
);
`
);
}
}
}
}
examples/diffhtml/package.json
View file @
c1075787
...
@@ -23,15 +23,16 @@
...
@@ -23,15 +23,16 @@
"babelify"
:
"^7.3.0"
,
"babelify"
:
"^7.3.0"
,
"browserify"
:
"^13.0.1"
,
"browserify"
:
"^13.0.1"
,
"derequire"
:
"^2.0.3"
,
"derequire"
:
"^2.0.3"
,
"diffhtml-inline-transitions"
:
"^1.0.0-rc3"
,
"mocha"
:
"^2.5.3"
,
"mocha"
:
"^2.5.3"
,
"transform-tagged-diffhtml"
:
"tbranyen/transform-tagged-diffhtml#588e6ed052616dafa87bf735787f7770bc6d8ba5"
,
"watchify"
:
"^3.7.0"
"watchify"
:
"^3.7.0"
},
},
"dependencies"
:
{
"dependencies"
:
{
"diffhtml"
:
"tbranyen/diffhtml#
a6570c577f1a08b78aca52ba68e19b4aed34c911
"
,
"diffhtml"
:
"tbranyen/diffhtml#
24ad47b9b76bd6a2ccc2882a5f22f69e507d14cc
"
,
"redux"
:
"^3.5.2"
,
"redux"
:
"^3.5.2"
,
"redux-logger"
:
"^2.6.1"
,
"redux-logger"
:
"^2.6.1"
,
"todomvc-app-css"
:
"^2.0.6"
,
"todomvc-app-css"
:
"^2.0.6"
,
"todomvc-common"
:
"^1.0.2"
,
"todomvc-common"
:
"^1.0.2"
"transform-tagged-diffhtml"
:
"tbranyen/transform-tagged-diffhtml#588e6ed052616dafa87bf735787f7770bc6d8ba5"
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment