scrollLeft bug chrome outside jsfddle - android

I have a scrollLeft function on a header so it is fixed vertically but scrolls horizontally. There is a bug in chrome for android where the header scrolls horizontally twice as fast as the rest of the page.
If I view this example in chrome for android it works as it should.
jsfiddle demo
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo</title>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'>
</script>
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<style type='text/css'>
#header {
height: 40px;
width: 900px;
background-color: red;
position: fixed;
z-index: 2; }
#content {
height: 1000px;
width: 900px;
background-color: blue;
top: 50px;
position: absolute;
z-index: 1; }
</style>
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$(window).scroll(function(){
$('#header').css('left', 8 - $(this).scrollLeft());
});
});//]]>
</script>
</head>
<body>
<div id="header">This is a fixed header that scrolls horizontally</div>
<div id="content">This is blah blah blah blah</div>
</body>
</html>
When I implement the code on a basic page as this page, the bug appears.
simple jsfiddle page
Somehow jsfiddle gets around the bug.

Changing
$('#header').css('left', 8 - $(this).scrollLeft());
to
$('#header').css('margin-left', 8 - $(this).scrollLeft());
and setting the fixed element to left:auto !important;
has resolved the issue!!!

Related

webview html rendering issue, image is getting cropped

I am trying to render an image as html in webview of android but not able to calibrate it correctly in mobile, original image gets cropped both left and right using below code. how should I fix this and how to know if it will render fine on mobile (by running in browser only) ? below is what I am doing.
image dimensions are:(624*936)
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charset="UTF-8" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP&display=swap"
/>
</head>
<body style="margin: 0; padding: 0; width: 100%; height: 100%">
<div
onclick="surface.touch()"
style="
background: url(https://image/startBackground_1)
center center fixed;
background-repeat: no-repeat;
height: 100%;
background-size: cover;
display: flex;
justify-content: flex-end;
flex-direction: column;
font-family: 'Noto Sans', sans-serif;
"
>
<div
style="margin-bottom: 100%; margin-top: 100%;"
></div>
</div>
</body>
</html>

CSS Scroll Snap Bug in Chrome on Android

I'm trying to implement full-size browser viewport scrolling using a CSS scroll-snap. But there is a problem with Chrome on Android (tested in 91 version): when the address bar shifts (at first scroll or on scroll direction change) scroll element can shake or/and scroll just partially — not to the correct element point. Please see a code snippet.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="wrapper">
<div class="wrapper__el" style="background: green">1</div>
<div class="wrapper__el">2</div>
<div class="wrapper__el" style="background: green">3</div>
<div class="wrapper__el">4</div>
<div class="wrapper__el" style="background: green">5</div>
<div class="wrapper__el">6</div>
<div class="wrapper__el" style="background: green">7</div>
<div class="wrapper__el">8</div>
<div class="wrapper__el" style="background: green">9</div>
</div>
<style>
html, body {
height: 100%;
margin: 0;
}
.wrapper {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
scroll-snap-type: mandatory;
scroll-snap-type: y mandatory;
overflow: scroll;
}
.wrapper__el {
scroll-snap-align: start;
scroll-snap-stop: always;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
</style>
</body>
</html>
Perhaps there are some ways to make this work smoothly and accurately using the CSS scroll-snap? At the same time, I would like to left the address bar moving in/out on Chrome on Android, as it is intended in this browser.

Ifream with google maps on mobile app

im building and app for android that use google maps embed with i frame all this on intel xdi plus cordova on html5 the problem is sometimes the apk show all black and it didn't show the map or is not well centre sometimes looks all fine but is like random pls some advice so fix that
<html>
<head></head>
<body>
<style>
.wrapper {
position: relative;
padding-bottom: 165%; // This is the aspect ratio
height: 0;
overflow: hidden;
}
.wrapper iframe {
position: absolute;
top: 0;
left: 0;
width: 100% !important;
height: 93% !important;
}
</style>
<div class="wrapper">
<iframe src="http://mapbuildr.com/frame/hc0v2v" frameborder="0"></iframe> </div>
</body>
</html>
Some old android devices dont initialize height and width immediately, try loading map after Cordova deviceready event is fired, here is sample code I tested, this loads the iframe src after deviceready event is fired:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<style>
.wrapper {
position: relative;
padding-bottom: 165%; // This is the aspect ratio
height: 0;
overflow: hidden;
}
.wrapper iframe {
position: absolute;
top: 0;
left: 0;
width: 100% !important;
height: 93% !important;
}
</style>
<script src="cordova.js"></script>
<script>
document.addEventListener("deviceready", function(){
document.getElementById("map").src = "http://mapbuildr.com/frame/hc0v2v";
}, false);
</script>
</head>
<body>
<div id="mapa_2" class="upage-content vertical-col left hidden">
<div class="wrapper">
<iframe id="map" src="" frameborder="0"></iframe>
</div>
</div>
</body>
</html>

Strange horizontal scrolling in Android browser

Check out the following demo on an Android device:
Scrolling Demo
There is a red box that is slightly off screen. When the vertical spacer is not present, you can't drag the page around in any direction. When the spacer is present and taking up more vertical space than the window, you can drag the page down (as expected) however, now you can also drag horizontally.
This only seems to happen on Android browsers. Any clues on what's going on here? I'd like to prevent the horizontal scrolling altogether while retaining vertical scrolling.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" id="viewportMobile" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" type="text/css" href="test.css" />
<style>
html,body {
overflow: hidden;
}
body {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow-y: visible;
overflow-x: hidden;
}
.offscreen {
position: absolute;
right: -20px;
background-color: #ed0021;
padding: 20px 20px 20px 20px;
}
</style>
<script>
var showSpacer=true;
function toggleSpacer() {
showSpacer = !showSpacer;
var spacer = document.getElementById('spacer');
spacer.style.display = showSpacer ? 'block' : 'none';
}
</script>
</head>
<body>
<div class="toggle-button" onClick="toggleSpacer()">Toggle Spacer</div>
<div class="offscreen"></div>
<div id="spacer" style="width:50px; height:2000px; background-color:#444">
</div>
</body>
</html>
Removing the overflow properties and changing the position to relative for the body element worked for me. It should look like this:
body {
position: relative;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
edit: bad copy/paste
edit 2: updated answer

Jsoup select element from CSS

How can I get all images without first class: content.slide0.
In my example I use Jsoup library, which show selectable elements in WebView.
Elements element = doc.select("HERE_SOLUTION");
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>TESTING TITLE</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="css/normalize.min.css">
<link rel="stylesheet" href="css/main.css?4231">
<script src="js/vendor/modernizr-2.6.2.min.js"></script>
<style type="text/css" media="screen">
body {
background: #fe9600 url('images/1389219790_bg2.jpg') no-repeat fixed top center;
}
#content.slide0 {
background: url('img/1234.jpg') no-repeat scroll top left;
width: 970px;
height: 474px;
margin: 0 auto;
}
#content.slide1 {
background: url('images/1235.jpg') no-repeat scroll top left;
width: 970px;
height: 474px;
margin: 0 auto;
}
#content.slide2 {
background: url('images/1236.jpg') no-repeat scroll top left;
width: 970px;
height: 474px;
margin: 0 auto;
}
Jsoup parses HTML but not CSS. Since you are attempting to get images from CSS, you cannot use Jsoup selectors. You should probably use regular expressions.
In you '.*' regex should extract
1. 'img/1234.jpg'
2. 'images/1235.jpg'
3. 'images/1236.jpg'
4. 'images/1389219790_bg2.jpg'
Last one may be unwanted. You can remove this probably checking length of string or so.
Alternatively you can use CSS parser like this.
Hope this helps!

Categories

Resources