jquery-animation.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>jquery animation &middot; Isotope </title>
  6. <!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
  7. <link rel="stylesheet" href="../css/style.css" />
  8. <!-- scripts at bottom of page -->
  9. </head>
  10. <body class="tests ">
  11. <nav id="site-nav">
  12. <h1><a href="../index.html">Isotope</a></h1>
  13. <h2>Docs</h2>
  14. <ul>
  15. <li><a href="../docs/introduction.html">Introduction</a>
  16. <li><a href="../docs/options.html">Options</a>
  17. <li><a href="../docs/methods.html">Methods</a>
  18. <li><a href="../docs/layout-modes.html">Layout modes</a>
  19. <li><a href="../docs/filtering.html">Filtering</a>
  20. <li><a href="../docs/sorting.html">Sorting</a>
  21. <li><a href="../docs/animating.html">Animating</a>
  22. <li><a href="../docs/adding-items.html">Adding items</a>
  23. <li><a href="../docs/extending-isotope.html">Extending Isotope</a>
  24. <li><a href="../docs/hash-history-jquery-bbq.html">Hash history with jQuery BBQ</a>
  25. <li><a href="../docs/help.html">Help</a>
  26. <li><a href="../docs/license.html">License</a>
  27. </ul>
  28. <h2>Demos</h2>
  29. <ul>
  30. <li><a href="../demos/basic.html">Basic</a>
  31. <li><a href="../demos/elements-complete.html">Elements Complete</a>
  32. <li><a href="../demos/elements-partial.html">Elements Partial</a>
  33. <li><a href="../demos/layout-modes.html">Layout modes</a>
  34. <li><a href="../demos/filtering.html">Filtering</a>
  35. <li><a href="../demos/sorting.html">Sorting</a>
  36. <li><a href="../demos/relayout.html">reLayout</a>
  37. <li><a href="../demos/adding-items.html">Adding items</a>
  38. <li><a href="../demos/infinite-scroll.html">Infinite Scroll</a>
  39. <li><a href="../demos/images.html">Images</a>
  40. <li><a href="../demos/combination-filters.html">Combination filters</a>
  41. <li><a href="../demos/hash-history.html">Hash history</a>
  42. <li><a href="../demos/fluid-responsive.html">Fluid / responsive</a>
  43. </ul>
  44. <h2>Custom layout modes</h2>
  45. <ul>
  46. <li><a href="../custom-layout-modes/centered-masonry.html">Centered Masonry</a>
  47. <li><a href="../custom-layout-modes/category-rows.html">Category rows</a>
  48. <li><a href="../custom-layout-modes/masonry-corner-stamp.html">Masonry corner stamp</a>
  49. <li><a href="../custom-layout-modes/masonry-gutters.html">Masonry gutters</a>
  50. <li><a href="../custom-layout-modes/spine-align.html">Spine align</a>
  51. </ul>
  52. <h2><a href="../tests/index.html">Tests</a></h2>
  53. </nav> <!-- #site-nav -->
  54. <section id="content">
  55. <h1>jquery animation</h1>
  56. <style>
  57. .isotope,
  58. .isotope .isotope-item {
  59. -webkit-transition: none;
  60. -moz-transition: none;
  61. transition: none;
  62. }
  63. </style>
  64. <section id="copy">
  65. <p>Check that the option setter for animationEngine is properly triggered.</p>
  66. </section>
  67. <section id="options" class="clearfix">
  68. <h3>Filters</h3>
  69. <ul id="filters" class="option-set clearfix" data-option-key="filter">
  70. <li><a href="#filter" data-option-value="*" class="selected">show all</a></li>
  71. <li><a href="#filter" data-option-value=".metal">metal</a></li>
  72. <li><a href="#filter" data-option-value=".transition">transition</a></li>
  73. <li><a href="#filter" data-option-value=".post-transition">post-transition</a></li>
  74. <li><a href="#filter" data-option-value=".nonmetal">nonmetal</a></li>
  75. <li><a href="#filter" data-option-value=".inner-transition">inner-transition</a></li>
  76. <li><a href="#filter" data-option-value=".alkali, .alkaline-earth">alkali and alkaline-earth</a></li>
  77. <li><a href="#filter" data-option-value=":not(.transition)">not transition</a></li>
  78. <li><a href="#filter" data-option-value=".metal:not(.transition)">metal but not transition</a></li>
  79. </ul>
  80. <h3>Sort</h3>
  81. <ul id="sort-by" class="option-set clearfix" data-option-key="sortBy">
  82. <li><a href="#sortBy=original-order" data-option-value="original-order" class="selected" data>original-order</a></li>
  83. <li><a href="#sortBy=name" data-option-value="name">name</a></li>
  84. <li><a href="#sortBy=symbol" data-option-value="symbol">symbol</a></li>
  85. <li><a href="#sortBy=number" data-option-value="number">number</a></li>
  86. <li><a href="#sortBy=weight" data-option-value="weight">weight</a></li>
  87. <li><a href="#sortBy=category" data-option-value="category">category</a></li>
  88. <li><a href="#sortBy=random" data-option-value="random">random</a></li>
  89. </ul>
  90. <h3>Sort direction</h3>
  91. <ul id="sort-direction" class="option-set clearfix" data-option-key="sortAscending">
  92. <li><a href="#sortAscending=true" data-option-value="true" class="selected">sort ascending</a></li>
  93. <li><a href="#sortAscending=false" data-option-value="false">sort descending</a></li>
  94. </ul>
  95. <h3>Etc</h3>
  96. <ul id="etc" class="clearfix">
  97. <li id="toggle-animation"><a href="#toggle-animation">Toggle jQuery animation</a></li>
  98. <li id="toggle-sizes"><a href="#toggle-sizes">Toggle variable sizes</a></li>
  99. </ul>
  100. </section> <!-- #options -->
  101. <div id="container" class="clickable clearfix">
  102. <div class="element other nonmetal " data-symbol="H" data-category="other">
  103. <p class="number">1</p>
  104. <h3 class="symbol">H</h3>
  105. <h2 class="name">Hydrogen</h2>
  106. <p class="weight">1.00794</p>
  107. </div>
  108. <div class="element noble-gas nonmetal " data-symbol="He" data-category="noble-gas">
  109. <p class="number">2</p>
  110. <h3 class="symbol">He</h3>
  111. <h2 class="name">Helium</h2>
  112. <p class="weight">4.002602</p>
  113. </div>
  114. <div class="element alkali metal " data-symbol="Li" data-category="alkali">
  115. <p class="number">3</p>
  116. <h3 class="symbol">Li</h3>
  117. <h2 class="name">Lithium</h2>
  118. <p class="weight">6.941</p>
  119. </div>
  120. <div class="element alkaline-earth metal " data-symbol="Be" data-category="alkaline-earth">
  121. <p class="number">4</p>
  122. <h3 class="symbol">Be</h3>
  123. <h2 class="name">Beryllium</h2>
  124. <p class="weight">9.012182</p>
  125. </div>
  126. <div class="element metalloid " data-symbol="B" data-category="metalloid">
  127. <p class="number">5</p>
  128. <h3 class="symbol">B</h3>
  129. <h2 class="name">Boron</h2>
  130. <p class="weight">10.811</p>
  131. </div>
  132. <div class="element other nonmetal " data-symbol="C" data-category="other">
  133. <p class="number">6</p>
  134. <h3 class="symbol">C</h3>
  135. <h2 class="name">Carbon</h2>
  136. <p class="weight">12.0107</p>
  137. </div>
  138. <div class="element other nonmetal " data-symbol="N" data-category="other">
  139. <p class="number">7</p>
  140. <h3 class="symbol">N</h3>
  141. <h2 class="name">Nitrogen</h2>
  142. <p class="weight">14.0067</p>
  143. </div>
  144. <div class="element other nonmetal " data-symbol="O" data-category="other">
  145. <p class="number">8</p>
  146. <h3 class="symbol">O</h3>
  147. <h2 class="name">Oxygen</h2>
  148. <p class="weight">15.9994</p>
  149. </div>
  150. <div class="element halogen nonmetal " data-symbol="F" data-category="halogen">
  151. <p class="number">9</p>
  152. <h3 class="symbol">F</h3>
  153. <h2 class="name">Fluorine</h2>
  154. <p class="weight">18.9984032</p>
  155. </div>
  156. <div class="element noble-gas nonmetal " data-symbol="Ne" data-category="noble-gas">
  157. <p class="number">10</p>
  158. <h3 class="symbol">Ne</h3>
  159. <h2 class="name">Neon</h2>
  160. <p class="weight">20.1797</p>
  161. </div>
  162. <div class="element alkali metal " data-symbol="Na" data-category="alkali">
  163. <p class="number">11</p>
  164. <h3 class="symbol">Na</h3>
  165. <h2 class="name">Sodium</h2>
  166. <p class="weight">22.98976928</p>
  167. </div>
  168. <div class="element alkaline-earth metal " data-symbol="Mg" data-category="alkaline-earth">
  169. <p class="number">12</p>
  170. <h3 class="symbol">Mg</h3>
  171. <h2 class="name">Magnesium</h2>
  172. <p class="weight">24.305</p>
  173. </div>
  174. <div class="element post-transition metal " data-symbol="Al" data-category="post-transition">
  175. <p class="number">13</p>
  176. <h3 class="symbol">Al</h3>
  177. <h2 class="name">Aluminium</h2>
  178. <p class="weight">26.9815386</p>
  179. </div>
  180. <div class="element metalloid " data-symbol="Si" data-category="metalloid">
  181. <p class="number">14</p>
  182. <h3 class="symbol">Si</h3>
  183. <h2 class="name">Silicon</h2>
  184. <p class="weight">28.0855</p>
  185. </div>
  186. <div class="element other nonmetal " data-symbol="P" data-category="other">
  187. <p class="number">15</p>
  188. <h3 class="symbol">P</h3>
  189. <h2 class="name">Phosphorus</h2>
  190. <p class="weight">30.973762</p>
  191. </div>
  192. <div class="element other nonmetal " data-symbol="S" data-category="other">
  193. <p class="number">16</p>
  194. <h3 class="symbol">S</h3>
  195. <h2 class="name">Sulfur</h2>
  196. <p class="weight">32.065</p>
  197. </div>
  198. <div class="element halogen nonmetal " data-symbol="Cl" data-category="halogen">
  199. <p class="number">17</p>
  200. <h3 class="symbol">Cl</h3>
  201. <h2 class="name">Chlorine</h2>
  202. <p class="weight">35.453</p>
  203. </div>
  204. <div class="element noble-gas nonmetal " data-symbol="Ar" data-category="noble-gas">
  205. <p class="number">18</p>
  206. <h3 class="symbol">Ar</h3>
  207. <h2 class="name">Argon</h2>
  208. <p class="weight">39.948</p>
  209. </div>
  210. <div class="element alkali metal " data-symbol="K" data-category="alkali">
  211. <p class="number">19</p>
  212. <h3 class="symbol">K</h3>
  213. <h2 class="name">Potassium</h2>
  214. <p class="weight">39.0983</p>
  215. </div>
  216. <div class="element alkaline-earth metal " data-symbol="Ca" data-category="alkaline-earth">
  217. <p class="number">20</p>
  218. <h3 class="symbol">Ca</h3>
  219. <h2 class="name">Calcium</h2>
  220. <p class="weight">40.078</p>
  221. </div>
  222. <div class="element transition metal " data-symbol="Sc" data-category="transition">
  223. <p class="number">21</p>
  224. <h3 class="symbol">Sc</h3>
  225. <h2 class="name">Scandium</h2>
  226. <p class="weight">44.955912</p>
  227. </div>
  228. <div class="element transition metal " data-symbol="Ti" data-category="transition">
  229. <p class="number">22</p>
  230. <h3 class="symbol">Ti</h3>
  231. <h2 class="name">Titanium</h2>
  232. <p class="weight">47.867</p>
  233. </div>
  234. <div class="element transition metal " data-symbol="V" data-category="transition">
  235. <p class="number">23</p>
  236. <h3 class="symbol">V</h3>
  237. <h2 class="name">Vanadium</h2>
  238. <p class="weight">50.9415</p>
  239. </div>
  240. <div class="element transition metal " data-symbol="Cr" data-category="transition">
  241. <p class="number">24</p>
  242. <h3 class="symbol">Cr</h3>
  243. <h2 class="name">Chromium</h2>
  244. <p class="weight">51.9961</p>
  245. </div>
  246. <div class="element transition metal " data-symbol="Mn" data-category="transition">
  247. <p class="number">25</p>
  248. <h3 class="symbol">Mn</h3>
  249. <h2 class="name">Manganese</h2>
  250. <p class="weight">54.938045</p>
  251. </div>
  252. <div class="element transition metal " data-symbol="Fe" data-category="transition">
  253. <p class="number">26</p>
  254. <h3 class="symbol">Fe</h3>
  255. <h2 class="name">Iron</h2>
  256. <p class="weight">55.845</p>
  257. </div>
  258. <div class="element transition metal " data-symbol="Co" data-category="transition">
  259. <p class="number">27</p>
  260. <h3 class="symbol">Co</h3>
  261. <h2 class="name">Cobalt</h2>
  262. <p class="weight">58.933195</p>
  263. </div>
  264. <div class="element transition metal " data-symbol="Ni" data-category="transition">
  265. <p class="number">28</p>
  266. <h3 class="symbol">Ni</h3>
  267. <h2 class="name">Nickel</h2>
  268. <p class="weight">58.6934</p>
  269. </div>
  270. <div class="element transition metal " data-symbol="Cu" data-category="transition">
  271. <p class="number">29</p>
  272. <h3 class="symbol">Cu</h3>
  273. <h2 class="name">Copper</h2>
  274. <p class="weight">63.546</p>
  275. </div>
  276. <div class="element transition metal " data-symbol="Zn" data-category="transition">
  277. <p class="number">30</p>
  278. <h3 class="symbol">Zn</h3>
  279. <h2 class="name">Zinc</h2>
  280. <p class="weight">65.38</p>
  281. </div>
  282. <div class="element post-transition metal " data-symbol="Ga" data-category="post-transition">
  283. <p class="number">31</p>
  284. <h3 class="symbol">Ga</h3>
  285. <h2 class="name">Gallium</h2>
  286. <p class="weight">69.723</p>
  287. </div>
  288. <div class="element metalloid " data-symbol="Ge" data-category="metalloid">
  289. <p class="number">32</p>
  290. <h3 class="symbol">Ge</h3>
  291. <h2 class="name">Germanium</h2>
  292. <p class="weight">72.64</p>
  293. </div>
  294. <div class="element metalloid " data-symbol="As" data-category="metalloid">
  295. <p class="number">33</p>
  296. <h3 class="symbol">As</h3>
  297. <h2 class="name">Arsenic</h2>
  298. <p class="weight">74.9216</p>
  299. </div>
  300. <div class="element other nonmetal " data-symbol="Se" data-category="other">
  301. <p class="number">34</p>
  302. <h3 class="symbol">Se</h3>
  303. <h2 class="name">Selenium</h2>
  304. <p class="weight">78.96</p>
  305. </div>
  306. <div class="element halogen nonmetal " data-symbol="Br" data-category="halogen">
  307. <p class="number">35</p>
  308. <h3 class="symbol">Br</h3>
  309. <h2 class="name">Bromine</h2>
  310. <p class="weight">79.904</p>
  311. </div>
  312. <div class="element noble-gas nonmetal " data-symbol="Kr" data-category="noble-gas">
  313. <p class="number">36</p>
  314. <h3 class="symbol">Kr</h3>
  315. <h2 class="name">Krypton</h2>
  316. <p class="weight">83.798</p>
  317. </div>
  318. <div class="element alkali metal " data-symbol="Rb" data-category="alkali">
  319. <p class="number">37</p>
  320. <h3 class="symbol">Rb</h3>
  321. <h2 class="name">Rubidium</h2>
  322. <p class="weight">85.4678</p>
  323. </div>
  324. <div class="element alkaline-earth metal " data-symbol="Sr" data-category="alkaline-earth">
  325. <p class="number">38</p>
  326. <h3 class="symbol">Sr</h3>
  327. <h2 class="name">Strontium</h2>
  328. <p class="weight">87.62</p>
  329. </div>
  330. <div class="element transition metal " data-symbol="Y" data-category="transition">
  331. <p class="number">39</p>
  332. <h3 class="symbol">Y</h3>
  333. <h2 class="name">Yttrium</h2>
  334. <p class="weight">88.90585</p>
  335. </div>
  336. <div class="element transition metal " data-symbol="Zr" data-category="transition">
  337. <p class="number">40</p>
  338. <h3 class="symbol">Zr</h3>
  339. <h2 class="name">Zirconium</h2>
  340. <p class="weight">91.224</p>
  341. </div>
  342. </div> <!-- #container -->
  343. <script src="../js/jquery-1.6.4.min.js"></script>
  344. <script src="../jquery.isotope.min.js"></script>
  345. <script>
  346. $(function(){
  347. var $container = $('#container');
  348. // add randomish size classes
  349. $container.find('.element').each(function(){
  350. var $this = $(this),
  351. number = parseInt( $this.find('.number').text(), 10 );
  352. if ( number % 7 % 2 === 1 ) {
  353. $this.addClass('width2');
  354. }
  355. if ( number % 3 === 0 ) {
  356. $this.addClass('height2');
  357. }
  358. });
  359. $container.isotope({
  360. itemSelector: '.element',
  361. transformsEnabled: false,
  362. animationEngine: 'jquery',
  363. masonry: {
  364. columnWidth : 120
  365. },
  366. getSortData : {
  367. symbol : function( $elem ) {
  368. return $elem.attr('data-symbol');
  369. },
  370. category : function( $elem ) {
  371. return $elem.attr('data-category');
  372. },
  373. number : function( $elem ) {
  374. return parseInt( $elem.find('.number').text(), 10 );
  375. },
  376. weight : function( $elem ) {
  377. return parseFloat( $elem.find('.weight').text().replace( /[\(\)]/g, '') );
  378. },
  379. name : function ( $elem ) {
  380. return $elem.find('.name').text();
  381. }
  382. }
  383. });
  384. var $optionSets = $('#options .option-set'),
  385. $optionLinks = $optionSets.find('a');
  386. $optionLinks.click(function(){
  387. var $this = $(this);
  388. // don't proceed if already selected
  389. if ( $this.hasClass('selected') ) {
  390. return false;
  391. }
  392. var $optionSet = $this.parents('.option-set');
  393. $optionSet.find('.selected').removeClass('selected');
  394. $this.addClass('selected');
  395. // make option object dynamically, i.e. { filter: '.my-filter-class' }
  396. var options = {},
  397. key = $optionSet.attr('data-option-key'),
  398. value = $this.attr('data-option-value');
  399. // parse 'false' as false boolean
  400. value = value === 'false' ? false : value;
  401. options[ key ] = value;
  402. if ( key === 'layoutMode' && typeof changeLayoutMode === 'function' ) {
  403. // changes in layout modes need extra logic
  404. changeLayoutMode( $this, options )
  405. } else {
  406. // otherwise, apply new options
  407. $container.isotope( options );
  408. }
  409. return false;
  410. });
  411. // change size of clicked element
  412. $container.delegate( '.element', 'click', function(){
  413. $(this).toggleClass('large');
  414. $container.isotope('reLayout');
  415. });
  416. // toggle variable sizes of all elements
  417. $('#toggle-sizes').find('a').click(function(){
  418. $container
  419. .toggleClass('variable-sizes')
  420. .isotope('reLayout');
  421. return false;
  422. });
  423. var isAnimated = true;
  424. $('#toggle-animation').click(function(){
  425. isAnimated = !isAnimated;
  426. var aniEngine = isAnimated ? 'jquery' : 'css';
  427. $container.isotope( 'option', { animationEngine: aniEngine } );
  428. return false;
  429. });
  430. });
  431. </script>
  432. <footer>
  433. Isotope by <a href="http://desandro.com">David DeSandro</a> / <a href="http://metafizzy.co">Metafizzy</a>
  434. </footer>
  435. </section> <!-- #content -->
  436. </body>
  437. </html>