ajax.html 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width" />
  6. <title>ajax</title>
  7. <link rel="stylesheet" href="../css/flickity.css" />
  8. <style>
  9. .gallery-cell {
  10. width: auto;
  11. height: 320px;
  12. }
  13. .gallery-cell img {
  14. height:100%;
  15. }
  16. </style>
  17. </head>
  18. <body>
  19. <h1>ajax</h1>
  20. <div class="gallery"></div>
  21. <script src="../bower_components/get-size/get-size.js"></script>
  22. <script src="../bower_components/desandro-matches-selector/matches-selector.js"></script>
  23. <script src="../bower_components/ev-emitter/ev-emitter.js"></script>
  24. <script src="../bower_components/unipointer/unipointer.js"></script>
  25. <script src="../bower_components/unidragger/unidragger.js"></script>
  26. <script src="../bower_components/fizzy-ui-utils/utils.js"></script>
  27. <script src="../bower_components/imagesloaded/imagesloaded.js"></script>
  28. <script src="../bower_components/jquery/dist/jquery.min.js"></script>
  29. <script src="../bower_components/jquery-bridget/jquery-bridget.js"></script>
  30. <script src="../js/cell.js"></script>
  31. <script src="../js/slide.js"></script>
  32. <script src="../js/animate.js"></script>
  33. <script src="../js/flickity.js"></script>
  34. <script src="../js/drag.js"></script>
  35. <script src="../js/prev-next-button.js"></script>
  36. <script src="../js/page-dots.js"></script>
  37. <script src="../js/player.js"></script>
  38. <script src="../js/add-remove-cell.js"></script>
  39. <script src="../bower_components/flickity-imagesloaded/flickity-imagesloaded.js"></script>
  40. <script>
  41. (function ($) {
  42. var url = "http://api.flickr.com/services/feeds/photos_public.gne?&format=json&jsoncallback=?&extras=url_n&per_page=10";
  43. $.getJSON(
  44. url).done(function (data) {
  45. var items = data.items;
  46. items.forEach(function (item) {
  47. var html = "<div class=\"gallery-cell\"><img src=\"" + item.media.m + "\" /></div>";
  48. $('.gallery').append(html);
  49. });
  50. $('.gallery').flickity({
  51. contain: true,
  52. freeScroll: true,
  53. friction: 0.2,
  54. imagesLoaded: true,
  55. prevNextButtons: false,
  56. pageDots: false,
  57. wrapAround: true
  58. });
  59. $(window).on('staticClick.flickity', function (event, pointer, clickedCellIndex, clickedCellElem) {
  60. console.log(clickedCellIndex, clickedCellElem);
  61. });
  62. });
  63. })(jQuery);
  64. </script>
  65. </body>
  66. </html>