H5 adaption animation js touch,

Source: Internet
Author: User

H5 adaption animation js touch,
Jquery. imgpreloadvar load_img = [];
Load_img.push ('HTTP: // m.pubuzhixing.com/Images/vote/music.gif ');
Load_img.push ('HTTP: // m.pubuzhixing.com/Images/vote/music_off.png'); // resource image loading
JQuery. imgpreload (load_img ,{
All: function (){
// Loading completed}); loading animation example http://www.cnblogs.com/lhb25/p/loading-spinners-animated-with-css3.html animation css3 animation @-webkit-keyframes jiantouan {from {}to {}} css style-webkit-animation-name: jiantouan; name
-Webkit-animation-iteration-count: infinite; playback times
-Webkit-animation-timing-function: linear; Playback Method
-Webkit-animation-delay: 0 s; delay duration
-Webkit-animation-direction: normal;
-Webkit-animation-duration: 1 s; animation duration-webkit-animation-fill-mode: forwards; after the animation is played, keep the final state. The overall H5 adaptation idea is calculated based on the aspect ratio of the design drawing and the actual width of the scene based on the height of the mobile phone screen, the layout of scene elements is based on the actual calculated width. The full screen display of the background image is stretched. For example, the ratio of the moving design diagram is generally 750*1334. the aspect ratio is 0.56var pageWidth = window. innerWidth;
Var pageHeight = window. innerHeight;
Var rwidth = 0.56 * pageHeight;
If (rwidth <pageWidth ){
Var left = (pageWidth-rwidth)/2;
$ (". Screen" ).css ({left: left, width: rwidth}); // set the width of the actual scenario.
} The background image should be integrated with the scenario; the background image should be separated from the scene element; // js touch slide upwards to monitor var startX and startY;
Function touchStart (event ){

If ($ (". screen. current"). hasClass ("cover_last ")){

}
Else {
Event. preventDefault (); blocks the default events of the browser
Var touch = event. touches [0];
StartX = touch. pageX;
StartY = touch. pageY;

}
}
Var touchuid = document. getElementById ("touchuid ");
Touchuid. addEventListener ('touchstart', touchstart, false );

Touchuid. addEventListener ('touchmove ', function (event ){
// If there is only one finger in the position of this element
If (event.tar getTouches. length = 1 ){
Var touch = event.tar getTouches [0];
If (startX ){
X = touch. pageX-startX;
Y = touch. pageY-startY;
// Alert (y );
If (y <-30) {// do your thing
StartX = 0;
StartY = 0;
}
}

}
}, False );

Related Article

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.