JS (MOBILE) package The mobile side some common methods

Source: Internet
Author: User

/** * Created by Administrator on 2016/7/14. *//* namespace */WINDOW.LCF = {};/* listens for the end of transition method */lcf.transitionend = function (obj,callback) {/* determines if obj is an object using typeof*/if (!ob J | |    typeof obj!== "Object") return false;    /* Listen for transition End Event */Obj.addeventlistener ("Webkittransitionend", function () {callback && callback ();    });    Obj.addeventlistener ("Transitionend", function () {callback && callback (); });};/  * Method of monitoring the end of transition */lcf.animationend = function (obj,callback) {/* determines if obj is an object */if (!obj | | typeof obj!== "Object") return    False    /* Listen for transition End Event */Obj.addeventlistener ("Webkitanimationend", function () {callback && callback ();    });    Obj.addeventlistener ("Animationend", function () {callback && callback (); });};/    * Add Transition method */lcf.addtransition =function (obj) {/* Basic judgment */if (!obj | | typeof obj!== "Object") return false;    obj.style.transition = "all 1s"; obj.style.webkitTransition = "all 1s";};/ * Removal of transition method */lcf.removetranSition =function (obj) {/* Basic judgment */if (!obj | | typeof obj!== "Object") return false;    Obj.style.transition = "None"; Obj.style.webkitTransition = "None";};/    * Up/down positioning method */lcf.settranslatey =function (Obj,translatey) {/* Basic judgment */if (!obj | | typeof obj!== "Object") return false;    Obj.style.transform = "Translatey (" +translatey+ "px)"; Obj.style.webkitTransform = "Translatey (" +translatey+ "px)";};/    * Left and right positioning method */lcf.settranslatex =function (Obj,translatex) {/* Basic judgment */if (!obj | | typeof obj!== "Object") return false;    Obj.style.transform = "TranslateX (" +translatex+ "px)"; Obj.style.webkitTransform = "TranslateX (" +translatex+ "px)";};/    * Package Tab Event Method */lcf.tap = function (obj,callback) {/* Basic judgment */if (!obj | | typeof obj!== "Object") return false;    /* Record time */var startTime = 0;    var ismove = false; /* trigger touch event when finger touches the screen */Obj.addeventlistener ("Touchstart", function (e) {/* Response start time (MS) */startTime = DATE.N    ow ();    }); /* Trigger Touch event when sliding screen */Obj.addeventlistener ("Touchmove", function (e) {/* swipe */ismove = true;    }); /* trigger touch event when finger leaves screen end */Obj.addeventlistener ("Touchend", function (e) {/* To determine response time */if ((Date.now ()-starttim        e) <150 &&!ismove) {callback && callback (e);        }/* Reset parameter */startTime = 0;    Ismove = false; });};/ * Countdown */lcf.downtime = function (endtime,obj,callback) {/* Basic judgment */if (!endtime | | typeof endTime!== "string") return F    Alse;    /* Basic judgment */if (!obj | | | typeof obj!== "Object") return false;    /* Get the date in milliseconds */var endTime = Date.parse (endTime);        /* Timer */setinterval (function () {var nowtime = +new Date ();        /*2 Time difference milliseconds */var minus =endtime-nowtime;        /* Difference in days */var day = parseint (MINUS/1000/60/60/24);        /* Difference in hours */var hours = parseint (minus/1000/60/60%24);        /* Difference in minutes */var mintue = parseint (minus/1000/60%60);        /* Get the difference in seconds */var second = parseint (minus/1000%60); obj[0].innerhtml = parseint (HOURS/10);        obj[1].innerhtml = hours%10;        obj[3].innerhtml = parseint (MINTUE/10);        obj[4].innerhtml = mintue%10;        obj[6].innerhtml = parseint (SECOND/10);    obj[7].innerhtml = second%10;    },1000); Callback && callback ();};

  

JS (MOBILE) package The mobile side some common methods

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.