Skip to content

Commit a841d30

Browse files
committed
Allow scaling backdrop to cover section instead of viewport
Prevent cropping important parts of the image when the section does not cover the whole viewport. This is a first step which does not yet cover all edge cases. Mainly works for sections with scroll-in/scroll-out transitions. REDMINE-21031
1 parent 7c97b42 commit a841d30

File tree

9 files changed

+100
-4
lines changed

9 files changed

+100
-4
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
de:
2+
pageflow:
3+
backdrop_size:
4+
feature_name: Hintergrundgröße-Option
5+
pageflow_scrolled:
6+
editor:
7+
edit_section:
8+
attributes:
9+
backdropSize:
10+
label: Hintergrund-Skalierung
11+
values:
12+
coverViewport: Viewport überdecken
13+
coverSection: Abschnitt überdecken
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
en:
2+
pageflow:
3+
backdrop_size:
4+
feature_name: Backdrop size option
5+
pageflow_scrolled:
6+
editor:
7+
edit_section:
8+
attributes:
9+
backdropSize:
10+
label: Backdrop scaling
11+
values:
12+
coverViewport: Cover viewport
13+
coverSection: Cover section

entry_types/scrolled/lib/pageflow_scrolled/plugin.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def configure(config)
5050
c.features.register('backdrop_content_elements')
5151
c.features.register('custom_palette_colors')
5252
c.features.register('decoration_effects')
53+
c.features.register('backdrop_size')
5354

5455
c.additional_frontend_seed_data.register(
5556
'frontendVersion',

entry_types/scrolled/package/src/editor/views/EditSectionView.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ export const EditSectionView = EditConfigurationView.extend({
4646
displayCheckedIfDisabled: true
4747
});
4848

49+
if (features.isEnabled('backdrop_size')) {
50+
this.input('backdropSize', SelectInputView, {
51+
visibleBinding: 'backdropType',
52+
visible: backdropType => backdropType === 'image' ||
53+
backdropType === 'video',
54+
values: ['coverViewport', 'coverSection']
55+
});
56+
}
57+
4958
this.input('backdropImage', FileInputView, {
5059
collection: 'image_files',
5160
fileSelectionHandler: 'sectionConfiguration',

entry_types/scrolled/package/src/frontend/Backdrop.module.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
visibility: hidden;
88
}
99

10+
.coverSection {
11+
container-type: size;
12+
--vh: 1cqh;
13+
}
14+
1015
.defaultBackground {
1116
background-color: #333;
1217
}

entry_types/scrolled/package/src/frontend/Section.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ function SectionContents({
130130
<>
131131
<Backdrop backdrop={backdrop}
132132
eagerLoad={section.sectionIndex === 0}
133+
size={section.backdropSize}
133134

134135
motifAreaState={motifAreaState}
135136
onMotifAreaUpdate={setMotifAreaRef}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React from 'react';
2+
3+
import {Entry, RootProviders} from 'pageflow-scrolled/frontend';
4+
5+
import {
6+
normalizeAndMergeFixture,
7+
exampleHeading,
8+
exampleTextBlock,
9+
filePermaId
10+
} from 'pageflow-scrolled/spec/support/stories';
11+
12+
import {storiesOf} from '@storybook/react';
13+
14+
storiesOf(`Frontend`, module)
15+
.add(
16+
'Backdrop Size',
17+
() =>
18+
<RootProviders seed={exampleSeed()}>
19+
<Entry />
20+
</RootProviders>
21+
)
22+
23+
function exampleSeed() {
24+
const sectionBaseConfiguration = {
25+
backdrop: {
26+
image: filePermaId('imageFiles', 'turtle')
27+
},
28+
backdropSize: 'coverSection',
29+
transition: 'reveal',
30+
fullHeight: false
31+
};
32+
33+
return normalizeAndMergeFixture({
34+
sections: [
35+
{
36+
id: 1,
37+
configuration: {
38+
...sectionBaseConfiguration
39+
}
40+
}
41+
],
42+
contentElements: exampleContentElements()
43+
});
44+
45+
function exampleContentElements() {
46+
return [
47+
exampleHeading({sectionId: 1, text: 'Backdrop size cover section'}),
48+
exampleTextBlock({sectionId: 1})
49+
];
50+
}
51+
}
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
.backdrop {
2-
position: sticky;
2+
position: absolute;
33
top: 0;
4-
height: 100vh;
4+
bottom: 0;
55
}
66

7-
.foreground {
8-
margin-top: -100vh;
7+
.backdropInner {
8+
position: sticky;
9+
top: 0;
10+
height: calc(100 * var(--vh));
911
}

entry_types/scrolled/package/src/frontend/v1/Backdrop/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const Backdrop = withInlineEditingDecorator('BackdropDecorator', function
1717
return (
1818
<div className={classNames(styles.Backdrop,
1919
{[styles.noCompositionLayer]: !shouldLoad && !props.eagerLoad},
20+
{[styles.coverSection]: props.size === 'coverSection'},
2021
props.transitionStyles.backdrop,
2122
props.transitionStyles[`backdrop-${props.state}`])}>
2223
<div className={classNames(props.transitionStyles.backdropInner,

0 commit comments

Comments
 (0)