Skip to content

Instantly share code, notes, and snippets.

@Duder-onomy
Created March 27, 2016 16:28
Show Gist options
  • Save Duder-onomy/43f580b65578a102ec05 to your computer and use it in GitHub Desktop.
Save Duder-onomy/43f580b65578a102ec05 to your computer and use it in GitHub Desktop.
Rivets rv-cloak example.
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title></title>
<style>
[rv-cloak] {
opacity: 0;
-webkit-transition: opacity 0.5s ease;
transition: opacity 0.5s ease;
}
</style>
</head>
<body>
<div id='binded'>
<ul rv-cloak>
<li rv-each-todo='list.todos'>
<span>{ todo.title }</span>
</li>
</ul>
</div>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js'></script>
<script src='https://cdn.rawgit.com/mikeric/rivets/master/dist/rivets.bundled.min.js'></script>
<script>
var list = {
todos: _createTodos()
};
jQuery(document).ready(function () {
rivets.bind($('#binded'), {list: list});
});
function _createTodos() {
var ary = [];
for(var i = 0; i < 10000; i++) {
ary.push({
title : 'Todo #'+ i
});
}
return ary;
}
rivets.binders.cloak = {
priority : -1000,
bind : function(el) {
el.style.opacity = 1;
}
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment