47, the JavaScript movement----the perfect motion frame application----Enlarges reduces the picture the realization (Layout transformation realization) __java

Source: Internet
Author: User

1, JavaScript motion----Perfect Motion frame application----enlarge and reduce the realization of the picture

2. Test code

2.1 Move.js

/** * can be easily obtained by non-row style value * @param {object} obj * @param {object} attr/function GetStyle (obj, attr) {if (obj.current
	Style) {return obj.currentstyle[attr];
	else {return getComputedStyle (obj, false) [attr]; }/** * To pay attention to the judgement of the motion stop condition * @param {object} obj * @param {object} JSON * @param {object} fn/function Startmove (obj, J
	Son, fn) {clearinterval (Obj.timer);
			Obj.timer = setinterval (function () {var bstop = true;//This time the campaign is over-all values have reached the for (Var attr in json) {//1. Take the current value ֵ

			var icur = 0;
			if (attr = = ' opacity ') {icur = parseint (parsefloat (obj, getstyle)) * 100);
			else {icur = parseint (GetStyle (obj, attr));
			//2 speed var ispeed = (json[attr]-icur)/8; Ispeed = ispeed > 0?

			Math.ceil (ispeed): Math.floor (Ispeed); 3. Check stop//To note that perfect motion frame motion stop detection is not the same as the detection of a single attribute stop//This is to wait for all the attributes, all have arrived, just stop the movement//So there is a property value is not arrived, will flag motion stop variable bstop set to False if (
			Icur!= json[attr]) {bstop = false; } if (attr = = ' opacity ') {Obj.stylE.filter = ' alpha (opacity: ' + (Icur + ispeed) + ') ';
			Obj.style.opacity = (icur + ispeed)/100;
			else {Obj.style[attr] = icur + ispeed + ' px ';

			}//4, for motion judgment if (bstop) {clearinterval (Obj.timer);
			if (FN) {fn (); }}, 30)}

2.2 HTML code

 

3. Test picture


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.