简体   繁体   English

图像加载时如何去除空白?

[英]how to remove white space when image loading?

My phone-gap app getting output I have 4 images sliding automatically it fixed any Device height and width my problem is while sliding images, I am getting white screen before image loading my code is :- 我的手机间隙应用程序获取输出,我有4张图像自动滑动,它固定了任何设备的高度和宽度,我的问题是滑动图像时,在图像加载代码之前,我出现白屏:-

<!DOCTYPE html>
<html>
<head>

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css">
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
<script src="http://responsiveslides.com/responsiveslides.min.js"></script>

<style>
    .caption {
        display: block;
        position: fixed;
        z-index: 2000;
        font-size: 20px;
        text-shadow: none
        color: #fff;
        background: #000;
        background: rgba(0,0,0, .8);
        left: 0;
        right: 0;
        bottom: 0;
        padding: 10px 20px;
        /*margin: -2;
        margin-top:-70px;*/
        max-width: none;
    }
    img {
        padding: 0;
        margin: 0;
    }
    .one{ 
        float:right
    }
    html, body {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
    }
    .ui-content {
        padding: 0;
        margin: 0;
    }
    #container {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
    }
</style>
<script>
    $(window).resize(function() {
        setHeight();
    });

    $(document).on('pageshow', '#index', function(){       
        setHeight();
    });

    function setHeight() {
        $.mobile.activePage.find('.ui-content').height(getRealContentHeight());
        $.mobile.activePage.find('img').height(getRealContentHeight()-4);   
    }

    function getRealContentHeight() {
        var header = $.mobile.activePage.find("div[data-role='header']:visible");
        var footer = $.mobile.activePage.find("div[data-role='footer']:visible");
        var content = $.mobile.activePage.find("div[data-role='content']:visible:visible");
        var viewport_height = $(window).height();

        var content_height = viewport_height - header.outerHeight() - footer.outerHeight() -2;
        if((content.outerHeight() - header.outerHeight() - footer.outerHeight()) <= viewport_height) {
            content_height -= (content.outerHeight() - content.height());
        } 
        return content_height;
    }
</script>
<body>
<div data-role="page" id="index">            
    <div data-role="content" class="slideshow">
        <div id="container">
            <img src="1.jpg" alt="" height="100%" width="auto"/><br/>
            <div  class="caption"> <font color="white">Second dfasdfasasdasdasdna asdasdasdasd asdasdasd asdasd<br/> asdasdasd asdadasd asdasdad</font><a href="http://www.google.com" style="text-decoration: none">&nbsp;&nbsp;<font color="white"><span class="one">skip</span></font></a></div>

        </div>

        <div id="container">
            <img src="2.jpg" alt=""/><br/>
            <div class="caption"><font color="white" >First Second dfasdfasasdasdasdna asdasdasdasd asdasdasd asdasd<br/> asdasdasd asdadasd asdasdad</font><a href="G:\html practise phonegap\responsive\validationform.html" style="text-decoration: none">&nbsp;&nbsp;<font color="white"><span class="one">skip</span></font></a>
            </div>
        </div>

        <div id="container">
            <img src="3.jpg" alt=""/><br/>
            <div class="caption"><font color="white" >three Second dfasdfasasdasdasdna asdasdasdasd asdasdasd asdasd<br/> asdasdasd asdadasd asdasdad</font><a href="G:\html practise phonegap\responsive\validationform.html" style="text-decoration: none">&nbsp;&nbsp;<font color="white"><span class="one">skip</span></font></a>
            </div>
        </div>

        <div id="container">
            <img src="4.jpg" alt=""/><br/>
            <div class="caption"><font color="white" >fourth Second dfasdfasasdasdasdna asdasdasdasd asdasdasd asdasd<br/> asdasdasd asdadasd asdasdad</font><a href="G:\html practise phonegap\responsive\validationform.html" style="text-decoration: none">&nbsp;&nbsp;<font color="white"><span class="one">skip</span></font></a>
            </div>
        </div>
    </div>
</div>
</body>
<script>


$(document).on('pageshow', '#index', function(){ 
    $(".slideshow > div:gt(0)").hide();

    setInterval(function() { 
        var currentSlide = $('.slideshow > div:visible:first'),
            nextSlide = currentSlide.next();

        currentSlide.fadeOut(1)
        nextSlide.fadeIn(2000);

        if ((currentSlide.index() + 1) == 4) {


       Redirect();

        }
    },  2000);
    function Redirect() {
        window.location="https://www.google.co.in";
    }
});

</script>
</html>

My code is working nice but when image sliding first white screen will be displayed and then images display 我的代码工作正常,但是当图像滑动时将先显示白屏,然后显示图像

How to hide the white screen? 如何隐藏白屏?

Demo 演示版

This seems to be a know issue running around for a while.This is due to jquery default page transition effects. 这似乎是一个运行一段时间的已知问题。这是由于jquery的默认页面过渡效果所致。 https://forum.jquery.com/topic/transition-flashing-showing-white-page-between-pages https://forum.jquery.com/topic/transition-flashing-showing-white-page-between-pages

The work around I did was the following code in my js .It worked.Hope it works for you too 我所做的工作是我的js中的以下代码,它起作用了,希望它也对您有用

$(document).bind("mobileinit", function () {
$.mobile.defaultPageTransition = 'none';
});

Just try overwritting transition effect as per your jQM version 只需按照您的jQM版本尝试覆盖过渡效果

This is a known problem in jQuery Mobile and turning backface visibility off helps to solve this problem to an extent. 这是jQuery Mobile中的一个已知问题,关闭背面可见性有助于在一定程度上解决此问题。 As per jQuery Mobile Docs 根据jQuery Mobile Docs

Some platforms currently have issues with transitions. 当前某些平台存在过渡问题。 We are working on a solution to solve the problem for everyone. 我们正在研究一种解决方案,以解决所有人的问题。 If you are experiencing flickers and flashes during or at the end of a transition we suggest the following workaround. 如果您在过渡期间或过渡结束时遇到闪烁和闪烁,我们建议采取以下解决方法。 Please note that this workaround should be thoroughly tested on the target platform before deployment. 请注意,在部署之前,应在目标平台上彻底测试此替代方法。 This workaround is known to cause performance issues and browser crashes on some platforms, especially Android. 已知此解决方法会导致性能问题,并且在某些平台(尤其是Android)上会导致浏览器崩溃。 Add the following code to your custom css. 将以下代码添加到自定义CSS中。

.ui-page { -webkit-backface-visibility: hidden; }

Only seeing fade transitions? 只看到淡入淡出过渡? To view all transition types, you must be on a browser that supports 3D transforms. 要查看所有过渡类型,您必须使用支持3D变换的浏览器。 By default, devices that lack 3D support (such as Android 2.x) will fallback to "fade" for all transition types. 默认情况下,缺少3D支持的设备(例如Android 2.x)对于所有过渡类型都将退回到“淡入淡出”状态。 This behavior is configurable (see below). 此行为是可配置的(请参见下文)。

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

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