Unusual performance issues observed in a flexbox when adjusting window size in mobile Chrome

Encountering an unusual issue with flexbox on a mobile browser.

For a visual demonstration, view this gif

Specifically happening on Chrome mobile on a Google Pixel phone. Using a resize script to adjust element sizes due to limitations with 100vh:

window.onresize = function() {
        document.getElementById("backgroundImage").style.height = window.innerHeight;
        document.getElementById("mainScreen").style.height = window.innerHeight;
        if (window.innerWidth > 750) {
          document.getElementById("scrollContent").style.height = window.innerHeight - "96";
        } else {
          document.getElementById("scrollContent").style.height = window.innerHeight - "72";
        }
    };

The issue occurs when scrolling to hide the navigation bar and clicking on one of the flex links.

Using Vuejs to dynamically populate content based on prop changes. Flex links trigger a function to switch project views.

Also adding a class to change link background colors upon selection.

var webComp = Vue.component('design-comp', {
  template: "#webComp",
  props:['trans-state'],
  components: {
      'project-comp': projectComp,
  },
  data: function() {
      return {
          activeProj: 'default',
      }
  },
  methods: {
      changeProj: function(proj) {
          this.activeProj = proj;
          var a = document.getElementsByClassName('projClick');
          for (i=0; i<a.length; i++) {
              a[i].classList.remove('projActive');
          }
          event.currentTarget.classList.add('projActive');
          document.getElementById('webContainer').scrollTop = 0;
      }
  },
  created: function() {
      this.activeProj = "default";
  }
});

Snippet from SASS file:

#webContainer {
  margin-top: 50px;
  height: calc(100% - 50px);
  .projHeader {
    display: flex;
    justify-content: center;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    background-color: $headerColor;
    box-sizing: border-box;

    .projClick {
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      height: 50px;
      box-sizing: border-box;
      background-color: $contentColor;
      border-right: 2px solid $headerColor;
      border-left: 2px solid $headerColor;
      border-bottom: 4px solid $headerColor;
      border-top: 4px solid $headerColor;
      flex-basis: 50px;
      transition: background-color 0.3s;

      &.projActive {
        background-color: $linkActiveColor;
      }

      p {
        color: $fontColor;
        font-family: $titleFont;
        font-size: 2em;
      }
    }
  }
}

HTML structure:

<div class="viewContainer" id="webContainer">
        <div class="transitionBox"></div>
        <div class="stickyImageBottomLeft"><img src="./img/AfricaMountainPixelR.gif" /></div>
        <div class="stickyImageBottomRight"><img src="./img/AfricaMountainPixel.gif" /></div>
        <div class="projHeader">
            <div class="projClick projActive" v-on:click="changeProj('default')">
                <p>0</p>
            </div>
            <div class="projClick" v-on:click="changeProj('kyount')">
                <p>1</p>
            </div>
            <div class="projClick" v-on:click="changeProj('prodigal')">
                <p>2</p>
            </div>
            <div class="projClick" v-on:click="changeProj('joy')">
                <p>3</p>
            </div>
            <div class="projClick" v-on:click="changeProj('cgl')">
                <p>4</p>
            </div>
            <div class="projClick" v-on:click="changeProj('mikeg')">
                <p>5</p>
            </div>
            <div class="projClick" v-on:click="changeProj('reddit')">
                <p>6</p>
            </div>
            <div class="projClick" v-on:click="changeProj('westbeach')">
                <p>7</p>
            </div>
        </div>
        <div class="contentContainer">
        Project Page is loaded here
        </div>
</div>

Seeking insights into the unexpected behavior occurring in this scenario.

Answer №1

Give this a shot:

#containerWeb {
  margin: 0;
  padding-top: 50px;
  height: 100%;
  box-sizing: border-box; /* if you haven't used it already */
...

Answer №2

Thanks to Kosh Very, I managed to discover a solution that functions flawlessly while preserving the desired style of the element.

#webContainer {
  margin-top: 50px;
  box-sizing: border-box;
  position: relative;
  height: 100%;

    .projHeader {
        ...
        position: fixed;
        ...
    }
}

I still suspect that the original issue is some kind of bug, but for now, this workaround is doing the job.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Executing javascript whenever a page is updated

Looking for a solution to ensure that my userscript runs every time an AJAX call modifies any page it is attached to. Is there a way to listen for XMLHttpRequests and trigger the script accordingly? ...

Live Search: Find Your Answers with Ajax

I've come across this issue multiple times, but haven't found a solution that fits my specific requirements. I've encountered several URLs with links like example.com/ajax/search?query=Thing I'm currently working on a header and using ...

blending the transition from dark image to black background

Utilizing the CSS below: #divPic { height: 32pc; background-image: url('https://wallpaperscraft.com/image/black_black_white_bone_time_game_noise_74543_4000x2248.jpg'); background-repeat: no-repeat; background-position: left center; b ...

Accessing the admin panel of a headless CMS using Nuxt.js and WordPress

I'm facing an issue. I recently set up Wordpress and enabled the REST API. Following that, I created a Nuxt.js app. The app runs on localhost:3000 (using "npm run dev" command) I configured XAMPP so that the document root of the server points to the ...

Having trouble with ESLint in VSCode? The ESLint extension seems to be ignoring linting rules after starting a new project within VSCode

I recently started using the ESLint extension in my VSCode editor for my React project. After creating the starter files, I ran the following command in my terminal: eslint --init This allowed me to choose the AirBnb style guide with React, which generat ...

Is there a way to use JavaScript to import several custom fonts at once?

Is there a way to import a long list of custom fonts as icons using Javascript? I have been obtaining the font list from an API, but importing them one by one with pure CSS using @font-face is time-consuming and difficult to maintain. @font-face { fon ...

The Art of Personalizing a Banner

I am currently experiencing an issue with the width of a specific gadget. My goal is to have the border-bottom line of #customheader span the entire width of any screen size. However, at the moment, the border-bottom is only the width of the blog itself. H ...

Having trouble with dynamic CSS not functioning properly when a checkbox is changed in Vue.js

I'm currently attempting to dynamically adjust the css styling of specific text within a span element by utilizing v-on:change on a checkbox. However, I am encountering an issue where the styling does not update as expected, and I am struggling to ide ...

How can I toggle input disablement in Bootstrap depending on switch selection?

I have been exploring the Bootstrap 5 documentation in search of a way to disable other input fields when a toggle switch input is set to 'off'. The parent element for this scenario is #member_form, and the switch itself is identified as 'to ...

Numeric value along with two characters following the decimal place

Imagine I have this number: 25297710.1088 My goal is to add spaces between the groups of digits and keep only two decimal places, like this: 25 297 710.10 I tried using the following code snippet: $(td).text().reverse().replace(/((?:\d{2})&bso ...

Upon clicking a button, initiate an Ajax call to retrieve a value from the code behind (aspx.cs) and display it in an input field on the same page

I am a beginner in the world of AJAX and encountering a problem. I need to initiate an AJAX call when a button is clicked. The goal is to send the value of an input field to the code behind page, aspx.cs, and then display the response from that same input ...

Failed attempt to perform Ajax requests for REST API data

I am currently working on developing an application that requires a login through a REST API to retrieve a session id. To achieve this, I have set up a button that triggers a JavaScript function for making an AJAX call to authenticate the user. The result ...

Developing a concealed Repeater element that is retained in the source code for utilization in JavaScript tasks

I am currently working on a setup with two repeaters: one that is displayed when the page first loads, and another that I want to keep hidden until a link called "Add Stuff" is clicked. My goal is to use JavaScript to make this second repeater visible upon ...

I am unable to apply CSS to style my <div> element

I've run into a snag with my coding project, specifically when attempting to style my div. Here is the code I have so far: All CSS rules are applying correctly except for the .chat rule. Can someone help me figure out what I'm doing wrong? var ...

What is the process for importing a Vue component into Vue and dynamically replacing a value within it?

Seeking guidance with VueJs as a new user. I'm looking to have a template loaded on every product page, where the ID of the product is dynamically substituted into the template. In my child Vue component, I am importing template.vue: <template> ...

Discover the process of loading one controller from another controller in Angular JS

Is it possible to load an entire controller1 from a different controller2, not just a function? ...

Is it possible to utilize the default error handling page rather than a specific view for expressing

Currently, I'm going through a tutorial on MDN Express for building a "Local Library" application that utilizes Pug (Jade) as its templating engine. In this segment of the tutorial, it explains the process of creating a controller to manage a form POS ...

Numerous websites with scroll-based navigation

I am currently building a unique website that includes scrolling in various directions without the use of a horizontal scrollbar. The design is similar to this image: https://i.stack.imgur.com/Ex2Bf.jpg. It is a one-page website where vertical scrolling ...

What is the significance of the error message '[WDS] Disconnected!' in the context of using webpack and Vue.js?

Currently, I am engaged in a Django project that utilizes Vue.js for the frontend. Whenever I refresh the page, I encounter the "[WDS] Disconnected!" error. Despite the website's full functionality and absence of issues, this error appears every time ...

Named Graph's Title on Image Save in Echarts

Is there a way to give a title to the image graph saved in Echarts, as Echarts does not have this option available? Any suggestions on how we can achieve this? Here is a link for reference from Echarts that provides the 'saveAsImage' option: Ch ...