简体   繁体   English

在加载页面时,Materialise CSS Preloader加载效果不佳

[英]Materialize CSS Preloader loads poorly when loading the page

I'm using Materialize CSS to make a quick personal site. 我正在使用Materialise CSS来创建一个快速的个人网站。 The site has a fullscreen image / hero when you load up but its big and takes a bit to load. 当你加载时,该网站有一个全屏图像/英雄,但它很大,需要加载一点。

In order to mitigate this I use the Materialize Circular Preloader ( http://materializecss.com/preloader.html ). 为了减轻这种影响,我使用了Materialise Circular Preloader( http://materializecss.com/preloader.html )。 However, it sort of jitters, glitches, slides around about 50% of the time I load the page. 然而,在我加载页面的时候,它有50%左右的抖动,毛刺,滑动。

I'm using Google Chrome which doesn't seem to have any open issues and it works sometimes. 我正在使用谷歌浏览器,它似乎没有任何未解决的问题,它有时会起作用。 Here is the standard CSS 这是标准的CSS

 <div class="preloader-wrapper big active">
    <div class="spinner-layer spinner-blue-only">
      <div class="circle-clipper left">
        <div class="circle"></div>
      </div><div class="gap-patch">
        <div class="circle"></div>
      </div><div class="circle-clipper right">
        <div class="circle"></div>
      </div>
    </div>
  </div>

And my script looks like this right now. 我的脚本现在看起来像这样。

     <script>
        // $(document).ready(function() {
        //     $('.preloader-wrapper').addClass('active');
        // });

        $(window).on('load', function() {
            $('.preloader').delay(350).fadeOut('slow');
            $('.preloader-wrapper').delay(350).fadeOut();
        });
    </script>

I tried loading the image later, only setting the preloader to active when the document was ready, other preloaders using SVG and CSS. 我稍后尝试加载图像,仅在文档准备好时将预加载器设置为活动状态,其他预加载器使用SVG和CSS。 I can't seem to figure out why it's so glitchy and all of these solutions fall prey to this also. 我似乎无法弄清楚为什么它如此微不足道,所有这些解决方案也成为这个问题的牺牲品。

Maybe something with keyframes? 也许有关键帧的东西? They all seem to use CSS keyframes. 他们似乎都使用CSS关键帧。

EDIT: Here is the site https://sarj21.github.io 编辑:这是网站https://sarj21.github.io

Since you are clearly hiding/showing elements with Javascript, I suggest setting all elements to display: none in your markup, then relying solely on Javascript to show them later. 由于您使用Javascript清楚地隐藏/显示元素,因此我建议将所有元素设置为在标记中display: none ,然后仅依靠Javascript在以后显示它们。 That should fix those kinds of quirks. 这应该解决这些怪癖。 I've used that trick with a lot of success. 我用这个技巧取得了很大的成功。

I think I fixed it, the issue seemed to be that the banner image was really big (something around 4000 x 2000 something). 我想我修好了,问题似乎是横幅图像真的很大(约4000 x 2000的东西)。 I made it smaller and everything loads much smoother and I see no issues with the loader :) 我把它缩小了,所有东西加载得更顺畅,我看到装载机没有问题:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM