Troubleshooting Vue.js rendering problems on Safari_BROWSER

I'm encountering a strange issue with my portfolio website, which is built using Vue and Laravel. The problem arises specifically in Safari - the project thumbnails don't display until the browser window is resized. Here's the relevant code snippet:

  <div class="project-list">
        <img v-show="!loaded" class="loading" src="../assets/contrast_load.gif" alt="loading...">
          <div class="project-container" v-for="project in shownProjects.slice().reverse()" v-bind:key="project.id">
            <figure class="project" @mouseover="gColor1 = project.color1; gColor2 = project.color2" @click="goToPage(project.id)" :style="`--overlay-color: ${project.color1};`">
              <img :src="`${base}/storage/app/${project.thumb_img}`" :alt="project.name" />
              <figcaption>
                <h3>{{ project.name }} <span v-bind:style="{color: project.color1}">{{ project.description }}</span></h3>
              </figcaption>
            </figure>
          </div>
      </div>
    </div>
  </div>
</template>

<script>
import LogoSVG from '../components/LogoSVG.vue';
import config from '../config';
import axios from 'axios';
export default {
  name: 'Portfolio',
  data(){
    return{
      search: '',
      projects: [],
      shownProjects: [],
      loaded: false,
      gColor1: '#752323',
      gColor2: '#e04747',
      base: config.BASE_URL,
    }
  },
  components:{
    LogoSVG,
  },
  watch:{
    search(){
      const vm = this;
      vm.shownProjects = [];
      if (vm.search == '') {
        vm.shownProjects = vm.projects;
      }
      else {
        for (var i = 0; i < vm.projects.length; i++) {
          if(vm.projects[i].tags.toLowerCase().search(vm.search.toLowerCase()) > -1){
            vm.shownProjects.push(vm.projects[i]);
          }
        }
      }
    },
  },
  methods:{
  getProjects(){
    const vm = this;
    vm.loaded = false;
    axios.get(`${config.APP_URL}/api/projects`)
    .then(function (response) {
        vm.projects = response.data;
        vm.shownProjects = response.data;
        window.onload = function() {
          vm.loaded = true;
        };
      });
    },
    goToPage(r){
      this.$router.push('project/' + r);
    },
  }
}
</script>

<style scoped>
  .loading{
    position: absolute;
    width: 50px;
    height: 50px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }


  .project-list{
    width: 90%;
    height: 70%;
    position: absolute;
    display: flex;
    display: -webkit-flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    left: 50%;
    top: 65%;
    transform: translate(-50%, -50%);
    align-content: flex-start;
    overflow-y: scroll;
    overflow-x: hidden;
  }

  .project-container{
    width: 33%;
    height: 30vh;
  }

  .project {
    background-color: #2A2A2A;
    color: #FFF;
    font-family: 'Roboto', sans-serif;
    font-size: 18px;
    margin: 8px;
    max-width: 100%;
    min-width: 230px;
    overflow: hidden;
    position: relative;
    text-align: center;
    width: 100%;
    height: 100%;
    cursor: pointer;
  }

  .project * {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    -webkit-transition: all 0.45s ease;
    transition: all 0.45s ease;
    cursor: pointer;
  }

  .project:after {
    background-color: var(--overlay-color);
    height: 150%;
    bottom: -145%;
    content: '';
    left: 0;
    right: 0;
    position: absolute;
    -webkit-transition: all 0.2s linear;
    transition: all 0.4s linear;
    cursor: pointer;
  }

  .project img {
    vertical-align: top;
    backface-visibility: hidden;
    max-height: 100%;
    object-fit: cover;
  }

  .project figcaption {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 10%;
    right: 10%;
    align-items: center;
    z-index: 1;
    display: flex;
    width: 80%;
    flex-direction: column;
    justify-content: center;
    line-height: 1.1em;
    opacity: 0;
    -webkit-transition-delay: 0s;
    transition-delay: 0s;
  }

  .project h3 {
    font-size: 1em;
    font-weight: 400;
    letter-spacing: 1px;
    margin: 0;
    text-transform: uppercase;
  }

  .project h3 span {
    display: block;
    font-weight: 700;
  }

  .project a {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1;
  }

  .project:hover > img,
  .project.hover > img {
    opacity: 0.1;
  }

  .project:hover:after,
  .project.hover:after {
    bottom: 95%;
  }

  .project:hover figcaption,
  .project.hover figcaption {
    opacity: 1;
    -webkit-transition-delay: 0.3s;
    transition-delay: 0.3s;
  }

  .project-fade-leave-active,
  .project-fade-enter-active {
    transition: 0.4s all;
  }
  .project-fade-enter,
  .project-fade-leave-to  {
    opacity: 0;
  }

  @-webkit-keyframes fadeDown {
    0%   {
      top: 4vh;
      opacity: 0;
    }
    100%{
      top: 5vh;
      opacity: 1;
    }
  }

  @-webkit-keyframes fade {
    0%   {
      opacity: 0;
    }
    100%{
      opacity: 1;
    }
  }
</style>

If you would like to take a look at the page yourself, here is the link:

Any assistance with fixing this issue would be greatly appreciated as it has been quite challenging to troubleshoot.

Answer №1

Discovered the problem. It seems that Safari doesn't handle data changes in Vue very well. I included an element that updates when all the other data is loaded, causing everything else to update as well.

Quite odd.

Answer №2

For future reference, I wanted to share some insights on how I got Safari to display the correct data from the state:

  • Make sure to include a v-bind directive in any element that is not updating properly. In my case, I used it like this:

    <div :key="targetObject.guid">
    .

  • Include dummy CSS properties for elements that need to be updated as well. Here are the ones I used:

.problematic-element {
   display: inline-block;
   min-width: 0%;
   transform: translateZ(0);
}

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 a jQuery function automatically & Invoking a jQuery function using the onClick attribute in an HTML element

Having some issues with jQuery and could use some assistance... Currently, I am trying to have a jQuery function automatically execute when the page loads, as well as when a button is clicked. [Previous Issue] Previously, the jQuery function would automa ...

Custom div element obstructs information window on map due to lack of auto panning feature

I created a unique div that is absolutely positioned on a Google Map. You can view the image below to see it. My issue is that the info window is being covered by this custom div element, as demonstrated in the picture. https://i.stack.imgur.com/1TgyQ.jpg ...

Is there a way to use HTML and CSS to switch the style of a dynamic decimal number to either Roman numerals or Katakana characters within a specified HTML element, such as a tag, div

I've searched everywhere but only found guides on list styling and counter styling in CSS that didn't work out. So, for example, I have a number inside an HTML tag that is changed dynamically using Vue Watch. I want to display the number in upper ...

Limiting the number of rows in a PHPexcel array

Is there a way to prevent the repcode from being empty if a specific name (array) is empty? I'm facing this issue with my excel report. Even when I only fill out 1 row in my form, the repcode is saved from 1 row to 10. Here is the current code: < ...

What steps can I take to generate a Vue instance using Jest when encountering an error message stating that "Vue

I need to troubleshoot a code that combines Vue and jQuery. The code makes use of jQuery to make REST API calls, and then the returned JSON data is processed with Vue. However, there seems to be an issue with it. During testing, I encountered the follow ...

When should the data in Vue.js be updated and re-rendered?

Just starting to dip my toes into Vue.js. I want to update the data in methods and dynamically change the view based on that data. // template <div v-if="currentGraphType.type === 'foo'"> <!-- Some other graphs --> </div> &l ...

The Role of Filling in a Process

I am looking to create a rectangle that fills up gradually every day, increasing by 1% each time. This is the basic concept. My main struggle is figuring out how to fill it up. I need the rectangle to increase by 1% of its width each day. So essentially, ...

When inline elements are positioned right next to block elements

Can inline and block elements be placed on the same level without wrapping in HTML? Does it matter if they are wrapped or not? For example: <div class="name"> <span class="name__text">List name</span> </div> <div class="li ...

My index.html not successfully linking to the CSS file

I'm new to this and still learning, so please bear with me. I'm having trouble linking my CSS file to my index.html document in order to create a black banner at the top of the page. I've tried opening it in both Chrome and Explorer but noth ...

Unexpected server error encountered during navigation of php pages

I am using PHP to retrieve data from a MySQL table and display it in an HTML table. Each row in the table has a 'remove' button that triggers a PHP script (remove.php) to delete the corresponding row from the database table and return to admin.ph ...

Tips on minimizing the vertical size of a mat field housing a mat-select dropdown

I need help reducing the height of a mat field that includes a mat-select in Angular v15. The code is directly from the material components documentation, with no alterations. It consists of a default table and default outline formfield. <mat-form-fi ...

A tag that does not adhere to the background color's rgba opacity restrictions

Can you believe what's happening to me? Check out this code snippet. I'm trying to apply an rgba color to my a tag, but it's acting like an rgb color instead of the intended rgba. The text background is solid, but the rest of the background ...

Can the Browser width/document width be maintained when shrinking the browser window size?

https://i.stack.imgur.com/a4gfA.pngLooking for a solution to maintain the browser/document width at 350px, preventing users from minimizing the window. The desired width is actually 400px, not 350px. Please refer to the image above. I require the window ...

Tips for customizing column width in v-simple-table with Vuetify.js component

For my most recent projects UI component, I decided to use vuetify.js. I attempted to adjust the width of the th and td elements within a v-simple-table using CSS, but unfortunately, nothing seemed to happen. My goal was to set the width of every th and td ...

A Nuxt plugin that integrates a separate website into the serverMiddleware

The concept Imagine having a main Nuxt website just like any other. Now, think about adding my module to your project. This module will then introduce a subdomain "admin.example.com" to your project, creating a fully functional Nuxt-based website that ope ...

The getimagesize functionality seems to be malfunctioning

I have developed a function that resizes images to fit as a background image for a div. I provide the function with the div size and the image path. It works perfectly when the height is larger than the width, but it fails when the width is larger than the ...

Retrieve the city value associated with a user's ID from the Laravel database

To retrieve the value from the privacy_settings table, specifically the city column, based on the user_id found in my view as {{ $user['id'] }} from the users table's id column. Below is a snippet of my controller code: public function ...

Tips for finding information within a table using HTML

My task involves creating a table with the option for users to search data within it. However, I have encountered an issue where I am only able to search for data in the first row of the table. <table style="width:100%" id="table"> <tr> ...

Vue.js optimized for search engines

Is there a simple method to optimize an existing Vue app for SEO and ensure that all header meta-tags are search engine-friendly? I have explored NUXT, but the thought of having to reconstruct the entire app is daunting. Additionally, I am not particularl ...

How to Use CSS to Align an Image in a Header

I'm struggling to position an image on the top right corner of my page, specifically in the header. Despite searching for help on Stack Overflow and other online resources, I can't seem to figure it out. Currently, here is what I have: The seco ...