当前位置:网站首页>2022 opening H5 mobile page special effects
2022 opening H5 mobile page special effects
2022-06-23 02:49:00 【Tanguangjian】
In the twinkling of an eye ,2022 Has come quietly ; Because I have been busy with the iteration and... Of a medium-sized project recently AR The launch of the project , Have been N I haven't published any technical articles for a long time ; The last one was last year Iot Introduction to the development of the development board sent by the students . Let's talk about it today H5 Special effects of mobile page ; all 2022 Return year H5? Can't H5 It's so popular , In particular, wechat has opened the external connection H5 It's important again . So let's talk about the recent development H5 Some of the experience .
1、 Mobile phone horizontal and vertical judgment
Mobile phones are the first in the world , Now mobile phones are basically 70% The carrier of ( The rest of the pad Slightly ); One problem is that the length, width and height of the vertical and horizontal screens are different , It will have an important impact on the overall page layout .
Here is how to automatically determine whether the screen is horizontal or vertical :
if ( window.orientation == 180 || window.orientation==0 ) {
alert(" Vertical screen ");
} else if( window.orientation == 90 || window.orientation == -90 ) {
alert(" Horizontal screen ");
}This is to enter the page for judgment , If you can judge whether the mobile phone is vertical or horizontal after entering it ? Of course it can , Go straight to the code :
window.addEventListener('orientationchange', function(event) {
if ( window.orientation == 180 || window.orientation==0 ) {
alert(" Vertical screen ");
} else if( window.orientation == 90 || window.orientation == -90 ) {
alert(" Horizontal screen ");
}
});2、 Turn to the whole page
Judge whether it is horizontal or vertical , Sometimes it can be handled by different layouts , But it takes a lot of energy , Because it needs to be done. 2 Set layout ; So I came up with a function to flip through the mirror image , Of course, I haven't applied this function yet . I used it anyway 2 Set layout processing .. tired . Here is the code for image flipping , It's simple, just in CSS Add in .
body {
-webkit-transform: rotate(90deg);
}So the whole page will turn clockwise 90°.. What's the role ? Existence is reason , It will be used in the future .
3、 Gravity induction of mobile phone and application of gyroscope
Now I can H5 Most of them are smart phones , Generally, it is equipped with gravity induction and gyroscope ; What about this 2 What's the use of one ? It can sense the angle and speed of the mobile phone . for instance : Shaking is actually used here 2 The data of two . This has an open source component Parallax.JS【http://matthew.wagerfield.com/parallax/】 I will not explain here , If you are interested, you can leave a message or go to see it yourself , I've also used this , I feel it is easy to start and realize ..
Let's say one last thing , Small H5 Apply directly to jq or jq mobile... Good maintenance ; Of course it's popular now VUE It's OK , But the feeling vue A little wide .. See what people think .
边栏推荐
- PNAs: power spectrum shows obvious bold resting state time process in white matter
- Biological psychiatry: defining individualized functional neuroanatomy for precision psychiatry
- [data preparation and Feature Engineering] data cleaning
- Delta oscillation in EEG
- Performance test -- 14 detailed explanation of performance test report and precautions
- How does the easyplayer streaming video player set up tiling?
- No error is reported when using the Gorm framework to create a table, but the data cannot be inserted successfully
- Simple implementation of promise basic method
- Small knowledge points of asset
- February 2, 2022: the closest binary search tree value II. Given a non empty two
猜你喜欢

Xgboost principle
What is sitelock? What is the function?

Spark broadcast variables and accumulators (cases attached)

6. template for integer and real number dichotomy

Performance test -- 14 detailed explanation of performance test report and precautions

Xgboost Guide

Docker installs mysql5.7 and mounts the configuration file

Third order magic cube formula

C language series - Section 4 - arrays

Custom shapes for ugui skill learning
随机推荐
PHP Base64 image processing Encyclopedia
The difference between script in head and body
Salesforce file (II) custom development fileUpload
Im web demo invite end hang up error avoidance
Troubleshooting and solution of 4K video cannot be played on easydss live video on demand platform
8. greed
Ping your domain name to 127.0.0.1. The solution to DNS hijacking
Daily shift series: memory problem of primary online service
Mobile communication Overview - Architecture
Docker builds MySQL master-slave
Learning notes of recommendation system (1) - Collaborative Filtering - Theory
How to gracefully solve the problem of platform font adaptation
Buuctf misc-[bjdctf2020] Nani
RI Geng series: potential memory leak caused by abuse of mutable in Google Pb structure
How to customize a finished label template
A bit about the state machine (FSM SMR DFSM)
Salesforce fileUpload (III) how to display uploaded images
Mongodb aggregate query implements multi table associated query, type conversion, and returns specified parameters.
Buuctf misc-[actf freshman competition 2020]outline
How to batch make decreasing serial number barcode