From e71bbaaac06571296ba188fb1b8e1cd09b4b950c Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 10 Nov 2023 12:50:43 -0600 Subject: [PATCH] Website: Add animation to "ClickOps or DevOps" image (#15064) Closes: #14990 Changes: - Updated the image in the "ClickOps or DevOps" section of the homepage to animate when it is scrolled into view. - Reduced the margin between the text block and the image in the "ClickOps or DevOps" section at 991px - 768px screen width. --- website/assets/js/pages/homepage.page.js | 23 +++++++++ website/assets/styles/pages/homepage.less | 57 +++++++++++++++++++---- website/views/pages/homepage.ejs | 7 ++- 3 files changed, 77 insertions(+), 10 deletions(-) diff --git a/website/assets/js/pages/homepage.page.js b/website/assets/js/pages/homepage.page.js index 51897dcc86..8a1e5aab6d 100644 --- a/website/assets/js/pages/homepage.page.js +++ b/website/assets/js/pages/homepage.page.js @@ -15,6 +15,11 @@ parasails.registerPage('homepage', { }, mounted: async function(){ + let imageToAnimate = document.querySelector('[purpose="platform-animated-image"]'); + // Make sure the animation event listener never runs if the image is removed. + if(imageToAnimate) { + this._addEventListenerForAnimation(imageToAnimate); + } }, // ╦╔╗╔╔╦╗╔═╗╦═╗╔═╗╔═╗╔╦╗╦╔═╗╔╗╔╔═╗ @@ -35,6 +40,24 @@ parasails.registerPage('homepage', { closeModal: function() { this.modal = undefined; + }, + + _addEventListenerForAnimation: function (imageToAnimate) { + window.addEventListener('scroll', ()=>{ + // Get the bounding box of the image. + let animatedImageBoundingBox = imageToAnimate.getBoundingClientRect(); + if (animatedImageBoundingBox.top >= 0 && + animatedImageBoundingBox.left >= 0 && + animatedImageBoundingBox.bottom <= (window.innerHeight || document.documentElement.clientHeight) && + animatedImageBoundingBox.right <= (window.innerWidth || document.documentElement.clientWidth)) + { + // When the image is completly in the user's viewport, add the 'animate' class to it. + imageToAnimate.classList.add('animate'); + } else if(imageToAnimate.classList.contains('animate')) { + // When it is no longer in the user's viewport, remove the 'animate' class if it has it. + imageToAnimate.classList.remove('animate'); + } + }); } } }); diff --git a/website/assets/styles/pages/homepage.less b/website/assets/styles/pages/homepage.less index f89e5e32af..300ed382b3 100644 --- a/website/assets/styles/pages/homepage.less +++ b/website/assets/styles/pages/homepage.less @@ -320,11 +320,50 @@ height: auto; } } - [purpose='platform-large-image'] { - width: 620px; + [purpose='platform-animated-image'] { + position: relative; + width: 617px; + height: 440px; img { width: 100%; - height: auto; + height: 100%; + } + div { + position: absolute; + top: 0; + right: 0; + height: 100%; + width: 100%; + transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); + } + [purpose='animated-image-layer-1'] { + background: url('/images/homepage-device-management-github-617x440@2x.png'); + background-size: contain; + background-position: center; + background-repeat: no-repeat; + z-index: 1; + transform: translate(10px, 10px); + } + [purpose='animated-image-layer-2'] { + background: url('/images/homepage-device-management-fleet-ui-617x440@2x.png'); + background-size: contain; + background-position: center; + background-repeat: no-repeat; + z-index: 2; + transform: translate(-10px, 10px); + } + [purpose='animated-image-layer-3'] { + background: url('/images/homepage-device-management-terminal-617x440@2x.png'); + background-size: contain; + background-position: center; + background-repeat: no-repeat; + z-index: 3; + transform: translate(10px, -10px); + } + &.animate { // This class is added when the element is completly visible. + div { + transform: none; + } } } [purpose='bottom-gradient'] { @@ -823,15 +862,16 @@ margin-left: 80px; } [purpose='platform-small-text-block'] { - max-width: 357px; - margin-right: 80px; + min-width: 320px; + margin-right: 20px; } - [purpose='platform-large-image'] { + [purpose='platform-animated-image'] { width: 453px; + height: auto; img { width: 100%; - height: auto; + height: 100%; } } @@ -936,13 +976,14 @@ } [purpose='platform-small-text-block'] { max-width: 100%; + min-width: unset; margin-right: 0px; margin-bottom: 80px; } [purpose='platform-image'] { width: 100%; } - [purpose='platform-large-image'] { + [purpose='platform-animated-image'] { width: 100%; img { width: 100%; diff --git a/website/views/pages/homepage.ejs b/website/views/pages/homepage.ejs index 08cce40563..4036146fda 100644 --- a/website/views/pages/homepage.ejs +++ b/website/views/pages/homepage.ejs @@ -223,8 +223,11 @@

Manage your IT infrastructure in any browser or use git to make infrastructure changes as code. You can use the CLI or API to automate the deployment, configuration, and monitoring of your devices.

Explore the docs -
- ClickOps or GitOps +
+
+
+
+ A blank image