generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/cloud image #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
634fe13
Creating cloud image block and additional logic
Srkkki 234ac36
Fix linting build errors
Srkkki d604503
Fix the build and linting rules
Srkkki 7abaf91
Fixing build and linting rules
Srkkki 8a626df
Fixing linting errors on build
Srkkki ab347cc
Fix build linting errors
Srkkki c548b4f
fixing css build rules
Srkkki 1bf3336
Fixing build linter rules
Srkkki a57b581
Encapsulating CSS styles, moving function excution into LoadEager exe…
Srkkki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| .cloud-image-wrapper { | ||
| height: 100vh; | ||
| position: relative; | ||
| } | ||
|
|
||
|
|
||
| .icon.icon-logo-big { | ||
| height: 100px; | ||
| width: 140px; | ||
| } | ||
|
|
||
| .cloud-image { | ||
| height: 100%; | ||
|
|
||
| & h1:first-of-type { | ||
| font-size: clamp(2rem, 7vw + .25rem, 5.625rem); | ||
| } | ||
| } | ||
|
|
||
| .cloud-image-header { | ||
| position: absolute; | ||
| width: 100%; | ||
| top: 50%; | ||
| left: 50%; | ||
| transform: translate(-50%, -50%); | ||
| opacity: 1; | ||
| z-index: 1; | ||
|
|
||
| } | ||
|
|
||
| .cloud-image-picture { | ||
| position: absolute; | ||
| top: 0; | ||
| left: 0; | ||
| max-width: 60vw; | ||
| max-height: 40vh; | ||
| animation: cloud 36s infinite; | ||
| animation-delay: 0s; | ||
| opacity: 0; | ||
| z-index: 0; | ||
| } | ||
|
|
||
| /* Keyframe cloud animation */ | ||
| @keyframes cloud { | ||
| 0% { | ||
| transform: scale(0.1); | ||
| filter: blur(10px); | ||
| opacity: 0; | ||
| } | ||
|
|
||
| 6% { | ||
| opacity: 1; | ||
| } | ||
|
|
||
| 13% { | ||
| filter: blur(0); | ||
| } | ||
|
|
||
| 25% { | ||
| filter: blur(0); | ||
| opacity: 1; | ||
| } | ||
|
|
||
| 33% { | ||
| transform: scale(1); | ||
| filter: blur(15px); | ||
| opacity: 0; | ||
| } | ||
|
|
||
| 100% { | ||
| opacity: 0; | ||
| } | ||
| } |
mbel-nc marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| function addClassToDivsWithPicture() { | ||
| const cloudImageElements = document.querySelectorAll('.cloud-image'); | ||
| cloudImageElements.forEach((cloudImage) => { | ||
| const childDivs = cloudImage.querySelectorAll(':scope > div'); | ||
| if (childDivs.length >= 2) { | ||
| const wrapper = document.createElement('div'); | ||
| wrapper.classList.add('cloud-image-header', 'text-center'); | ||
| childDivs[0].before(wrapper); | ||
| wrapper.appendChild(childDivs[0]); | ||
| wrapper.appendChild(childDivs[1]); | ||
| } | ||
|
|
||
| childDivs.forEach((div) => { | ||
| if (div.querySelector('picture')) { | ||
| div.classList.add('cloud-image-picture'); | ||
| } | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| function setDataAttributes() { | ||
| // Arrays for top and left values calculation (mocked from the original site that seems random) | ||
| const topValues = [ | ||
| 20, 0, 50, 70, 100, 60, 90, 20, 0, 40, | ||
| 90, 80, 60, 60, 90, 10, 40, 50, 80, | ||
| ]; | ||
| const leftValues = [ | ||
| 50, 90, 60, 80, 30, 80, 0, 20, 60, 90, | ||
| 10, 70, 100, 30, 90, 0, 50, 90, 90, 30, | ||
| ]; | ||
| const delayValues = [ | ||
| 4, 5, 2, 34, 3, 7, 8, | ||
| 9, 15, 15, 12, 22, 20, 26, 33, 31, 25, 27, | ||
| ]; | ||
| const cloudImagePictureElements = document.querySelectorAll('.cloud-image-picture'); | ||
|
|
||
| cloudImagePictureElements.forEach((div, index) => { | ||
| const leftIndex = index % leftValues.length; | ||
| const topIndex = index % topValues.length; | ||
| const delayIndex = index % delayValues.length; | ||
| div.setAttribute('data-left', leftValues[leftIndex]); | ||
| div.setAttribute('data-top', topValues[topIndex]); | ||
| div.setAttribute('data-delay', delayValues[delayIndex]); | ||
| }); | ||
| } | ||
|
|
||
| function positionImageInTheCloud() { | ||
| const cloudImgContainer = document.querySelector('.cloud-image-wrapper'); | ||
| const cloudImagePictureElements = document.querySelectorAll('.cloud-image-picture'); | ||
|
|
||
| const { | ||
| width: containerWidth, | ||
| height: containerHeight, | ||
| } = cloudImgContainer.getBoundingClientRect(); | ||
|
|
||
| cloudImagePictureElements.forEach((element) => { | ||
| const img = element.querySelector('img'); | ||
| if (!img) return; | ||
| const { width: imgWidth, height: imgHeight } = img; | ||
| const elementStyleTop = `${element.dataset.left * (1 - imgWidth / containerWidth)}`; | ||
| const elementStyleLeft = `${element.dataset.top * (1 - imgHeight / containerHeight) * 0.96}`; | ||
| element.style.left = (elementStyleLeft > 60) ? `${60}%` : `${elementStyleLeft}%`; | ||
| element.style.top = (elementStyleTop > 57) ? `${57}%` : `${elementStyleTop}%`; | ||
| element.style.animationDelay = `${element.dataset.delay - 36}s`; | ||
| }); | ||
| } | ||
|
|
||
| export default positionImageInTheCloud; | ||
|
|
||
| addClassToDivsWithPicture(); | ||
| setDataAttributes(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.