问题
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 :-
<!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"> <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"> <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"> <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"> <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
回答1:
This seems to be a know issue running around for a while.This is due to jquery default page transition effects.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
$(document).bind("mobileinit", function () {
$.mobile.defaultPageTransition = 'none';
});
Just try overwritting transition effect as per your jQM version
回答2:
This is a known problem in jQuery Mobile and turning backface visibility off helps to solve this problem to an extent. As per 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. Add the following code to your custom 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. By default, devices that lack 3D support (such as Android 2.x) will fallback to "fade" for all transition types. This behavior is configurable (see below).
来源:https://stackoverflow.com/questions/23670417/how-to-remove-white-space-when-image-loading