transition.html 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title></title>
  5. <meta charset="utf-8">
  6. <script src="bind.js"></script>
  7. <script src="../../../dist/seed.js"></script>
  8. <style type="text/css">
  9. .test {
  10. width: 600px;
  11. height: 100px;
  12. background-color: #f00;
  13. padding: 10px;
  14. border: 1px solid #000;
  15. overflow: hidden;
  16. transition: all 1s ease;
  17. -moz-transition: all .2s ease;
  18. -webkit-transition: all .2s ease;
  19. }
  20. .sd-enter, .sd-leave {
  21. height: 0;
  22. padding-top: 0;
  23. padding-bottom: 0;
  24. border-top-width: 0;
  25. border-bottom-width: 0;
  26. }
  27. .sd-enter {
  28. background-color: #00f;
  29. }
  30. .sd-leave {
  31. background-color: #0f0;
  32. }
  33. </style>
  34. </head>
  35. <body>
  36. <div id="test">
  37. <div>
  38. <button class="button-0" sd-on="click:set">0</button>
  39. <button class="button-1" sd-on="click:set">1</button>
  40. <button class="button-2" sd-on="click:set">2</button>
  41. <button class="push" sd-on="click:push">push</button>
  42. <button class="pop" sd-on="click:pop">pop</button>
  43. <button class="splice" sd-on="click:splice">splice</button>
  44. </div>
  45. <div
  46. class="test"
  47. sd-repeat="item:items"
  48. sd-if="filter(item)"
  49. sd-transition
  50. sd-attr="data-id:item.a">
  51. {{item.a}}
  52. </div>
  53. <div
  54. class="test"
  55. sd-repeat="item:items"
  56. sd-show="filter(item)"
  57. sd-transition
  58. sd-attr="data-id:item.a">
  59. {{item.a}}
  60. </div>
  61. </div>
  62. <h1 style="margin:0">123</h1>
  63. <script>
  64. var test = new Seed({
  65. el: '#test',
  66. scope: {
  67. b: 1,
  68. set: function (e) {
  69. this.b = +e.el.textContent
  70. },
  71. push: function () {
  72. this.items.push({a: this.items.length + 1 })
  73. },
  74. pop: function () {
  75. this.items.pop()
  76. },
  77. splice: function () {
  78. this.items.splice(0, 1, {a:99})
  79. },
  80. filter: function (item) {
  81. return item.a > this.b
  82. },
  83. items: [
  84. {
  85. a: 1
  86. },
  87. {
  88. a: 2
  89. }
  90. ]
  91. }
  92. })
  93. </script>
  94. </body>
  95. </html>