Skip to content

Commit

Permalink
[FEATURE] responsive background images for parallax element (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmh authored and MattiasNilsson committed May 17, 2017
1 parent a8fcc37 commit 4782fa9
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 2 deletions.
103 changes: 103 additions & 0 deletions Configuration/TypoScript/Library/lib.responsiveBackgroundImage.setupts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
lib.responsiveBackgroundImage = TEXT
lib.responsiveBackgroundImage {
current = 1
wrap = responsiveBg|

append = LOAD_REGISTER
append {
t3kit_responsiveBackgroundImage = TEXT
t3kit_responsiveBackgroundImage {
prepend = TEXT
prepend {
data = register:t3kit_responsiveBackgroundImage
wrap = |,
required = 1
}

current = 1
trim = 1
}
}

}

page.cssInline {
1450 = FILES
1450 {

references.data = register:t3kit_responsiveBackgroundImage

renderObj = COA
renderObj {
5 = LOAD_REGISTER
5 {
mediaImageIndex = TEXT
mediaImageIndex {
cObject = TEXT
cObject {
data = register:sectionIteration
intval = 1
outerWrap = |+1
}

prioriCalc = 1
}
}

10 = TEXT
10 {
prepend = TEXT
prepend {
data = file:current:uid
noTrimWrap = |.responsiveBg| { background-image: url(/|
}

cObject = IMG_RESOURCE
cObject {
file {
import.data = file:current:uid
treatIdAsReference = 1
width = 767
}
}

append = TEXT
append {
value = ); }
}
}

20 = TEXT
20.cObject < .10
20 {
cObject.cObject.file.width = 992px
noTrimWrap = | @media (min-width: 768px) { | } |
}

30 = TEXT
30.cObject < .10
30 {
cObject.cObject.file.width = 1920
noTrimWrap = | @media (min-width: 992px) { | } |
}
60 = TEXT
60.cObject < .10
60 {
cObject.cObject.file.width = 1000
noTrimWrap = | @media (max-width: 767px) and (-webkit-min-device-pixel-ratio: 2), (max-width: 767px) and (min-resolution: 2dppx) { | } |
}
70 = TEXT
70.cObject < .10
70 {
cObject.cObject.file.width = 1536
noTrimWrap = | @media (min-width: 768px) and (-webkit-min-device-pixel-ratio: 2), (min-width: 768px) and (min-resolution: 2dppx) { | } |
}
80 = TEXT
80.cObject < .10
80 {
cObject.cObject.file.width = 2400
noTrimWrap = | @media (min-width: 992px) and (-webkit-min-device-pixel-ratio: 2), (min-width: 992px) and (min-resolution: 2dppx) { | } |
}
}
}
}
37 changes: 37 additions & 0 deletions Resources/Private/Layouts/GridElements/NoBgImage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:spaceless>

<f:comment><!-- ### Wrapper class===frame_class||Margin Top===space_before_class||Margin Bottom===space_after_class ### --></f:comment>
<f:if condition="({data.frame_class} && ({data.frame_class} != 'default')) || {data.space_before_class} || {data.space_after_class}">
<div class="{data.frame_class} {data.space_before_class} {data.space_after_class}">
</f:if>

<f:comment><!-- ### element body ### --></f:comment>
<div id="c{data.uid}" class="frame frame-type-{data.CType} {layoutClass} {f:if(condition: data.layout, then: ' frame-layout-{data.layout}')} {alignClass} {f:if( condition: data.flexform_container, then: ' {data.flexform_container}')}">
<f:if condition="{data._LOCALIZED_UID}">
<a id="c{data._LOCALIZED_UID}"></a>
</f:if>
<f:render section="Before" optional="true">
<f:render partial="DropIn/Before/All" arguments="{_all}" />
</f:render>
<f:render section="Header" optional="true">
<f:render partial="Header/All" arguments="{_all}" />
</f:render>

<f:render section="Main" optional="true" />

<f:render section="Footer" optional="true">
<f:render partial="Footer/All" arguments="{_all}" />
</f:render>
<f:render section="After" optional="true">
<f:render partial="DropIn/After/All" arguments="{_all}" />
</f:render>
</div>

<f:comment><!-- ### Wrapper class===frame_class||Margin Top===space_before_class||Margin Bottom===space_after_class ### --></f:comment>
<f:if condition="({data.frame_class} && ({data.frame_class} != 'default')) || {data.space_before_class} || {data.space_after_class}">
</div>
</f:if>

</f:spaceless>
</html>
4 changes: 2 additions & 2 deletions Resources/Private/Templates/GridElements/Parallax.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<f:layout name="Default" />
<f:layout name="NoBgImage" />
<f:section name="Main">
<f:if condition="{files.0}">
<f:if condition="{files.0.type} == 4">
Expand All @@ -11,7 +11,7 @@
</f:if>
</f:if>
<f:if condition="{files.0.type} == 2">
<div class="parallax parallax-img {f:if(condition: data.pi_flexform.data.columns.lDEF.hideInMobile.vDEF, then: ' hidden-xs hidden-sm')}" style="background-image: url('{f:uri.image(image : files.0.originalFile)}'); height: {f:if(condition: data.pi_flexform.data.columns.lDEF.height.vDEF, then: data.pi_flexform.data.columns.lDEF.height.vDEF, else: 'auto')};" >
<div class="parallax parallax-resimg {f:cObject(typoscriptObjectPath:'lib.responsiveBackgroundImage', data:files.0.uid)} {f:if(condition: data.pi_flexform.data.columns.lDEF.hideInMobile.vDEF, then: ' hidden-xs hidden-sm')}" style="height: {f:if(condition: data.pi_flexform.data.columns.lDEF.height.vDEF, then: data.pi_flexform.data.columns.lDEF.height.vDEF, else: 'auto')};" >
</f:if>
</f:if>
<f:format.raw>{data.tx_gridelements_view_column_0}</f:format.raw>
Expand Down
9 changes: 9 additions & 0 deletions felayout_t3kit/dev/js/main/contentElements/parallax.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
noAndroid: false,
noIos: true
})
$('.parallax-resimg').each(function () {
$(this).jarallax({
type: 'scroll', // scroll, scale, opacity, scroll-opacity, scale-opacit
speed: 0.5,
noAndroid: false,
imgSrc: $(this).css('background-image').trim().slice(5, -2),
noIos: true
})
})
$('.parallax-video').jarallax({
type: 'scroll', // scroll, scale, opacity, scroll-opacity, scale-opacit
speed: 0.5,
Expand Down

0 comments on commit 4782fa9

Please sign in to comment.