NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

gallery.vue 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template lang="pug">
  2. .gallery.f-col.center(v-if="fullscreengallery")
  3. button(@click="hideGallery").hide hide
  4. ul
  5. li(v-for="(image, i) of images" :class="{ active: i === selected }")
  6. .image-wrapper.f-col.center
  7. img(:src="image")
  8. .controls.f-row
  9. button(@click="prev") <
  10. .f-grow
  11. button(@click="next") >
  12. </template>
  13. <script>
  14. export default {
  15. props: {
  16. images: { type: Array },
  17. fullscreengallery: { type: Boolean },
  18. startwith: { type: Number }
  19. },
  20. data() {
  21. return {
  22. selected: 0
  23. }
  24. },
  25. methods: {
  26. prev() {
  27. this.selected > 0 ? this.selected-- : this.selected = this.images.length - 1
  28. },
  29. next() {
  30. this.selected < this.images.length - 1 ? this.selected++ : this.selected = 0
  31. },
  32. hideGallery() {
  33. this.$emit('close')
  34. },
  35. interpretKeypress(e) {
  36. switch (e.key) {
  37. case 'ArrowRight':
  38. this.next()
  39. break
  40. case 'ArrowLeft':
  41. this.prev()
  42. break
  43. case 'Escape':
  44. this.hideGallery()
  45. break
  46. }
  47. }
  48. },
  49. created() {
  50. this.selected = this.startwith
  51. },
  52. mounted() {
  53. window.addEventListener('keydown', this.interpretKeypress)
  54. },
  55. destroyed() {
  56. window.removeEventListener('keydown', this.interpretKeypress)
  57. }
  58. }
  59. </script>
  60. <style lang="postcss">
  61. .gallery
  62. position: fixed
  63. top: 0
  64. left: 0
  65. width: 100%
  66. height: 100%
  67. background-color: black
  68. z-index: 1001
  69. > *
  70. opacity: 100%
  71. position: relative
  72. z-index: 1011
  73. button.hide
  74. z-index: 1100
  75. ul
  76. list-style: none
  77. li
  78. display: none
  79. &.active
  80. display: block
  81. .image-wrapper
  82. height: 100%
  83. width: 50vw
  84. background-color: yellow
  85. h1
  86. color: green
  87. .controls
  88. position: absolute
  89. width: 100vw
  90. button
  91. height: 100vw
  92. padding: 1vw
  93. </style>