Mobile Front End Series – Mobile page pit and pit tips

Source: Internet
Author: User

# # Video tag out of document flow

Problem Description: Label's parent element (ancestor Element) after setting the transform style, the label is detached from the document flow

Test environment: Some Android models

Workaround: Do not use the Transform property. Translate use top, margin and other attributes instead

# #:: After use of animation in the phone is not valid

Problem Description::: After the phone does not support animation

Workaround: Do not change the pseudo element to a normal element

# # page Height rendering error

Problem Description: Page 100% height contains the address bar height, when the address bar exists, some of the content is hidden

Environment and frequency: recurring; each mobile browser

Workaround: Reset Height: document.documentElement.style.height = window.innerheight + ' px '

# # Overlay Area highlighting

Problem Description: Using Click also occurs when a bound hit area flashes

Environment and frequency: some Android models

WORKAROUND: Give the element a style-webkit-tap-highlight-color:rgba (0,0,0,0);

# # event cannot be triggered

Problem Description: Focus, touch, click and other events are not valid

Environment and frequency: Android part model

Workaround: Add-webkit-transform:translate3d (0,0,0) to the element in its CSS property

# #: Active effect is not compatible

Problem Description: Invalid CSS active Pseudo-class

Environment and frequency: Android 4.2 or less

Workaround: The element's Touch Series event binding an empty anonymous method

   Element.addeventlistener (' Touchstart ', function () {},false);   

# # Browser crashes

Problem Description: The Unbind function is written in event handling causing a crash

Environment and frequency: Millet

Workaround: Unbind events do not write in event handling

# # Pre-loaded and AutoPlay not valid

Problem Description: Audio preload, AutoPlay cannot be directly affected by the environment and frequency: affected by the operating system, browser (webview), version, etc.

WORKAROUND: Once the user input is captured, let the audio load implement preload

   Play and pause it once   document.addeventlistener (' Touchstart ', function () {   document.getElementsByTagName ( ' Audio ') [0].play ();   document.getElementsByTagName (' audio ') [0].pause ();   });   

# # Cannot play multiple audio simultaneously

Problem Description: Playing the last audio will interrupt the previous audio, and will not sync the broadcast

Environment and frequency: Android

Solution: Reasonable down right and choose different audio, different audio to create the atmosphere as consistent as possible.

# # does not support local scrolling

Problem Description: Invalid Overflow:scroll except body (HTML) element

Environment and frequency: Android 2.X

Solution: 1, skillfully use the layout of the body (HTML) Global Scrolling 2, iscroll, self-write JS control translate, scrolltop simulation

# # Input:password Password input box appears suspended weird input box

Description of the problem: strange suspended form

Environment and frequency: some Android models

Workaround: Use the Input:text type rather than the password type and set its settings-webkit-text-security:disc; Hide input Password to resolve

# # Video tag out of document flow

Problem Description: Label's parent element (ancestor Element) after setting the transform style, the label is detached from the document flow

Test environment: Some Android models

Workaround: Do not use the Transform property. Translate use top, margin and other attributes instead

# # Cannot get wide height when initializing page

Problem Description: The built-in browser is not the same as our JQ or Zoto method, not universal

Test environment: Inline browser

Workaround:

var inter=setinterval (function () {    if ($win. Width ()) {        //Your code
Clearinterval (inter); }},10);

# # Different units can not be used on the phone side

Problem Description: If 100% does not show any inconsistency on the phone side

Test environment:/

Workaround: 100px, 100%

# # WebKit 90 degrees from the standard color gradient direction

Problem Description: WebKit and standard color gradient direction 90 degrees Background:-webkit-linear-gradient (0deg, #3d86c8, Rgba (61,134,200,0) 25%,rgba ( 61,134,200,0) 75%, #3d86c8); Background:linear-gradient (90deg, #3d86c8, Rgba (61,134,200,0) 25%,rgba (61,134,200,0) 75% , #3d86c8);

Test environment:/

# # Flexbox child element settimeout not rendered

Problem description: Flexbox child element settimeout not rendered

Test environment:/

WORKAROUND:/

# # sub-element horizontal floating height:100% calculation error

Problem Description: child element Horizontal floating height:100% calculation error

Test environment: QQ Browser

WORKAROUND:/

# # Canvas Todataurl exporting data failed

Problem Description: Canvas Todataurl exporting data failed

Test environment: QQ Browser

WORKAROUND:/

# # Touchmove prevents bubbling, and the underlying element touchend will not execute

Problem Description: Touchmove block bubbling, underlying element touchend will not execute

Test environment:/

WORKAROUND:/

# # QQ Browser introduced JS file cache

Problem Description: QQ Browser introduced JS file cache

Test environment: Android QQ Browser

WORKAROUND:/

1. Appearance A, page height rendering error

In each mobile browser often appear this page height 100% rendering error, the low end of the page and the system comes with the navigation bar coincident, the height is not correct we need to reset it, reset it by JavaScript code:

Document.documentElement.style.height = window.innerheight + ' px ';
B, overlay area highlighting

In some Android models, click on a section of the page may appear in the yellow box of the second Flash, which is the default custom style of some models of the system itself, to the element a CSS style reset:

-webkit-tap-highlight-color:rgba (0,0,0,0);
2, Behavior A, events can not be triggered

In the context of some Android models where events cannot be triggered and forms cannot be entered, we set the style for elements that require input or triggering events:-webkit-transform:translate3d (0,0,0), but the new version has been directly fixed the problem.

B: The active effect is not compatible

In the Android 4.0 version of the following CSS: Theactive pseudo-state effect is incompatible, we bind an empty anonymous method to the element's Touch Series event (Touchstart/touchend/touchmove):

var Element=document.getelementsbyid ("Btnshare"); Element.addeventlistener (' Touchstart ', function () {},false);
3. Application A, browser crashes

act = function () {Window.removeeventlistener (' devicemotion ', act);}; Window.addeventlistener (' devicemotion ', act,false);

The Unbind function is written in the event processing to cause the crash of the Xiaomi phone, so we do not write the time of the Unbind in event processing.

B, pre-load, autoplay invalid

As shown in the table above, after a simple test to find that preload, the effectiveness of AutoPlay is affected by the operating system, browser (webview), version, etc., Apple Official rules must be manually triggered by the user to load audio, then we capture a user input, let the audio load implementation preload:

Play and pause it once  document.addeventlistener ('touchstart ', function () {  document.getElementsByTagName (' audio ') [0].play ();  document.getElementsByTagName (' audio ') [0].pause ();  });
C. Cannot play multiple audio simultaneously

In Android device, play after one audio will interrupt the previous audio, but not synchronized playback, this is the current system senior decision, we only take the elegant down the right way to let Android choose a different style of audio and video before and after the switch playback instead of playing simultaneously, to achieve with the expected close audio effect.

D, partial scrolling is not supported

The Overflow:scroll style setting ScrollBar is not valid for elements other than the body (HTML) element below the Android 4.0 version, there are two solutions:

1, skillfully with the layout directly set the style scroll bar on the body (HTML), the other elements "illusion scrolling."

2, using Iscroll, self-write JS control translate, scrolltop simulation

4, System/Hardware A, strange suspension of the form

In some Android models the input box may appear weird superfluous flyout, after observation and testing found that only the Input:password type of input box exists, then we just use input: The text type of the input box and-webkit-text-security:disc through the style; Hide the input password to resolve.

B, error appears scroll bar

In the Game inline page appears the scroll bar should not appear, and the content does not exceed the content area width, after the test Overflow:hidden invalid, through a series of attempts to use the ancient <body scroll= "No" > Writing solution, Try a different way of writing and attributes will be a surprise Oh!

C, link open System Browser

It is a very bad experience to have a click-through link to invoke the System browser in some Android models that are webview in-game. Then we try to add the target= "_blank" property to this element is possible to resolve, if it is not resolved then need to modify the iOS or Android native system functions.

D, Flex box is not compatible

In the game embedded WebView in the case of the Flex box layout is incompatible, the figure shows that the following part of the navigation dislocation, although the previous careful review of the Flex box compatibility, but in the game embedded page can not be determined that its call system browser version and compatibility, resulting in an error, So we write the full history version of the 3 kinds of flex box solution. Then we think in the process of writing a page or in a conservative and stable way to write style can reduce the trouble.

faced with so many pits, there are all kinds of already and unknown pits, time can not be finished, more unlikely to have a solution, we need to learn how to solve the pit:

To solve the pit you need to have a strong executive power, through the constant attempt to explore the unknown problems, then what are the general steps and techniques we will try?

1, first we need to locate the problem, we can use the following methods:

A, Dom Isolation location method

Dom elements that are constantly isolated from a wide range to a small range to isolate and trigger problems

B, style, JS culling method

Constantly remove some js, CSS watch debugging check whether it is caused by some JS, CSS properties problems

C, multi-run environmental testing method

Test in a multi-environment to see if it is caused by a specific environment

D, PC and mobile phone joint debugging method

United PC and mobile phone positioning, such as: remote debugging via Mac Iphone/ipad

2, we can try to solve the problem in the following ways:

* Try, turn your mind around and solve

* Graceful down right, differentiated treatment, communication

* Search and ask questions ...

And the following thinking:

* Alternative

* Detour

* Split ...

3, in the process of solving the problem, we need to learn to use search and communication resources to solve the problem:

A, Google

B, StackOverflow

C, colleagues, friends, QQ Group, forum, etc.

Google and StackOverflow make it easier for you to quickly search for more accurate information about problems, as well as friends QQ groups, forums and so on so that you can directly communicate with others about the problem and solutions.

After discovering and solving the problem, it is more important to learn how to summarize the problem:

A, summarize record the problem to produce the condition, the solution method and the solution process

B, as far as possible to analyze the principle, the conditions produced, avoid repeating

C, share to more people

Endless pit, walk more people, summed up the share of more, the pit is more and more flat

We summarize the records of the problem at the same time, organized a mobile tip, record problems and some pits, although not perfect at present but hope to share to more people also hope that more people can participate in the improvement.

Links: https://github.com/tgideas/mtips

Mobile Front End Series – Mobile page pit and pit tips

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.