frontblocks-before-after-frontend.js
2 months ago
frontblocks-before-after-option.jsx
1 month ago
frontblocks-before-after.css
1 month ago
frontblocks-before-after.js
1 month ago
frontblocks-before-after.css
146 lines
| 1 | /* ============================================================================= |
| 2 | Before After Block — FrontBlocks |
| 3 | ============================================================================= */ |
| 4 | |
| 5 | .frbl-before-after { |
| 6 | position: relative; |
| 7 | overflow: hidden; |
| 8 | cursor: col-resize; |
| 9 | -webkit-user-select: none; |
| 10 | user-select: none; |
| 11 | touch-action: pan-y; |
| 12 | display: block; |
| 13 | width: 100%; |
| 14 | } |
| 15 | |
| 16 | /* After image — defines the block height */ |
| 17 | .frbl-before-after__after { |
| 18 | position: relative; |
| 19 | width: 100%; |
| 20 | display: block; |
| 21 | } |
| 22 | |
| 23 | .frbl-before-after__after img { |
| 24 | display: block; |
| 25 | width: 100%; |
| 26 | height: auto; |
| 27 | pointer-events: none; |
| 28 | } |
| 29 | |
| 30 | /* Fixed height mode: images scale to fit without cropping */ |
| 31 | .frbl-before-after--fixed-height .frbl-before-after__after { |
| 32 | position: absolute; |
| 33 | top: 0; |
| 34 | left: 0; |
| 35 | width: 100%; |
| 36 | height: 100%; |
| 37 | } |
| 38 | |
| 39 | .frbl-before-after--fixed-height .frbl-before-after__after img, |
| 40 | .frbl-before-after--fixed-height .frbl-before-after__before img { |
| 41 | width: 100%; |
| 42 | height: 100%; |
| 43 | object-fit: cover; |
| 44 | object-position: center; |
| 45 | } |
| 46 | |
| 47 | /* Before image — absolutely positioned on top, clipped from the right */ |
| 48 | .frbl-before-after__before { |
| 49 | position: absolute; |
| 50 | top: 0; |
| 51 | left: 0; |
| 52 | width: 100%; |
| 53 | height: 100%; |
| 54 | overflow: hidden; |
| 55 | clip-path: inset( 0 50% 0 0 ); |
| 56 | } |
| 57 | |
| 58 | .frbl-before-after__before img { |
| 59 | display: block; |
| 60 | width: 100%; |
| 61 | height: 100%; |
| 62 | object-fit: cover; |
| 63 | pointer-events: none; |
| 64 | } |
| 65 | |
| 66 | /* Labels */ |
| 67 | .frbl-before-after__label:empty { |
| 68 | display: none; |
| 69 | } |
| 70 | |
| 71 | .frbl-before-after__label { |
| 72 | position: absolute; |
| 73 | top: 16px; |
| 74 | padding: 4px 12px; |
| 75 | background: rgba( 0, 0, 0, 0.55 ); |
| 76 | color: #fff; |
| 77 | font-size: 13px; |
| 78 | font-weight: 600; |
| 79 | line-height: 1.4; |
| 80 | border-radius: 3px; |
| 81 | letter-spacing: 0.02em; |
| 82 | z-index: 5; |
| 83 | pointer-events: none; |
| 84 | } |
| 85 | |
| 86 | .frbl-before-after__label--before { |
| 87 | left: 16px; |
| 88 | } |
| 89 | |
| 90 | .frbl-before-after__label--after { |
| 91 | right: 16px; |
| 92 | } |
| 93 | |
| 94 | /* Handle */ |
| 95 | .frbl-before-after__handle { |
| 96 | position: absolute; |
| 97 | top: 0; |
| 98 | bottom: 0; |
| 99 | left: 50%; |
| 100 | transform: translateX( -50% ); |
| 101 | width: 44px; |
| 102 | display: flex; |
| 103 | flex-direction: column; |
| 104 | align-items: center; |
| 105 | z-index: 10; |
| 106 | cursor: col-resize; |
| 107 | } |
| 108 | |
| 109 | .frbl-before-after__handle:focus { |
| 110 | outline: none; |
| 111 | } |
| 112 | |
| 113 | .frbl-before-after__handle:focus-visible .frbl-before-after__handle-thumb { |
| 114 | outline: 2px solid #007cba; |
| 115 | outline-offset: 2px; |
| 116 | } |
| 117 | |
| 118 | .frbl-before-after__handle-line { |
| 119 | flex: 1; |
| 120 | width: 2px; |
| 121 | background: #fff; |
| 122 | box-shadow: 0 0 4px rgba( 0, 0, 0, 0.4 ); |
| 123 | } |
| 124 | |
| 125 | .frbl-before-after__handle-thumb { |
| 126 | flex-shrink: 0; |
| 127 | width: 44px; |
| 128 | height: 44px; |
| 129 | border-radius: 50%; |
| 130 | background: #fff; |
| 131 | box-shadow: 0 2px 10px rgba( 0, 0, 0, 0.35 ); |
| 132 | display: flex; |
| 133 | align-items: center; |
| 134 | justify-content: center; |
| 135 | color: #555; |
| 136 | } |
| 137 | |
| 138 | .frbl-before-after__handle-thumb svg { |
| 139 | display: block; |
| 140 | } |
| 141 | |
| 142 | /* Editor — handle stays interactive for the drag preview */ |
| 143 | .frbl-before-after--editor { |
| 144 | cursor: col-resize; |
| 145 | } |
| 146 |