deprecated
2 weeks ago
_swiper._scss
2 months ago
block.json
2 weeks ago
edit-multiItem.js
2 weeks ago
edit-slider.js
2 weeks ago
edit.js
1 day ago
icon.svg
2 months ago
index.js
2 months ago
index.php
2 months ago
loop-min-slides.js
2 months ago
pause-button.js
1 day ago
save.js
1 day ago
style.scss
2 months ago
view.js
1 day ago
save.js
111 lines
| 1 | import { InnerBlocks, useBlockProps } from '@wordpress/block-editor'; |
| 2 | import { PauseButton } from './pause-button'; |
| 3 | |
| 4 | export default function save({ attributes }) { |
| 5 | const { |
| 6 | pagination, |
| 7 | blockId, |
| 8 | width, |
| 9 | autoPlay, |
| 10 | autoPlayStop, |
| 11 | autoPlayDelay, |
| 12 | pauseButton, |
| 13 | loop, |
| 14 | effect, |
| 15 | speed, |
| 16 | slidesPerViewMobile, |
| 17 | slidesPerViewTablet, |
| 18 | slidesPerViewPC, |
| 19 | slidesPerGroup, |
| 20 | navigationPosition, |
| 21 | centeredSlides, |
| 22 | zoomAnimation, |
| 23 | zoomInitialScale, |
| 24 | zoomFinalScale, |
| 25 | direction, |
| 26 | } = attributes; |
| 27 | |
| 28 | const sliderData = { |
| 29 | autoPlay, |
| 30 | autoPlayStop, |
| 31 | autoPlayDelay, |
| 32 | pauseButton, |
| 33 | pagination, |
| 34 | width, |
| 35 | loop, |
| 36 | effect, |
| 37 | speed, |
| 38 | direction, |
| 39 | slidesPerViewMobile, |
| 40 | slidesPerViewTablet, |
| 41 | slidesPerViewPC, |
| 42 | slidesPerGroup, |
| 43 | centeredSlides, |
| 44 | zoomAnimation, |
| 45 | zoomInitialScale, |
| 46 | zoomFinalScale, |
| 47 | blockId, |
| 48 | }; |
| 49 | |
| 50 | let alignClass = ''; |
| 51 | if ('full' === width) { |
| 52 | alignClass = ' alignfull'; |
| 53 | } else if ('wide' === width) { |
| 54 | alignClass = ' alignwide'; |
| 55 | } |
| 56 | |
| 57 | // ページネーションの HTML |
| 58 | let pagination_html = ''; |
| 59 | if (pagination !== 'hide') { |
| 60 | pagination_html = ( |
| 61 | <div |
| 62 | className={`swiper-pagination swiper-pagination-${pagination}`} |
| 63 | ></div> |
| 64 | ); |
| 65 | } |
| 66 | |
| 67 | // ナビゲーションの HTML |
| 68 | let navigation_next_html = ''; |
| 69 | let navigation_prev_html = ''; |
| 70 | if (navigationPosition !== 'hide') { |
| 71 | navigation_next_html = ( |
| 72 | <div |
| 73 | className={`swiper-button-next swiper-button-${navigationPosition}`} |
| 74 | ></div> |
| 75 | ); |
| 76 | navigation_prev_html = ( |
| 77 | <div |
| 78 | className={`swiper-button-prev swiper-button-${navigationPosition}`} |
| 79 | ></div> |
| 80 | ); |
| 81 | } |
| 82 | |
| 83 | const blockProps = useBlockProps.save({ |
| 84 | className: `swiper swiper-container vk_slider vk_slider_${blockId}${alignClass}`, |
| 85 | }); |
| 86 | |
| 87 | // 停止/再生ボタンの HTML(自動再生が有効かつ表示設定が ON の時のみ出力)。 |
| 88 | // ⚠️ ボタンはスライダーのルート直下に置くこと。view.js が |
| 89 | // :scope > .swiper-pause-button で直下のみを検索するため、ラッパーで囲むと |
| 90 | // 停止/再生ボタンと「視差効果を減らす」対応が機能しなくなる |
| 91 | // (保存出力の変更になるため deprecation も� |
| 92 | 要になる)。 |
| 93 | // ⚠️ Keep this button a DIRECT CHILD of the slider root: view.js locates it |
| 94 | // with ':scope > .swiper-pause-button', so wrapping it breaks the pause/play |
| 95 | // button and the reduced-motion handling (changing the saved markup would |
| 96 | // also require a block deprecation). |
| 97 | const pause_button_html = autoPlay && pauseButton ? <PauseButton /> : ''; |
| 98 | |
| 99 | return ( |
| 100 | <div {...blockProps} data-vkb-slider={JSON.stringify(sliderData)}> |
| 101 | <div className={`swiper-wrapper`}> |
| 102 | <InnerBlocks.Content /> |
| 103 | </div> |
| 104 | {navigation_next_html} |
| 105 | {navigation_prev_html} |
| 106 | {pagination_html} |
| 107 | {pause_button_html} |
| 108 | </div> |
| 109 | ); |
| 110 | } |
| 111 |