JS Display, Hidden function

Source: Internet
Author: User

var hide = function (OBJ,SPEED,FN) {
obj = $ (obj);

if (!speed) {
Obj.style.display = ' None ';
Return
}
else{
Speed = speed=== ' fast '? 20:speed=== ' normal '? 30:50;
Obj.style.overflow = ' hidden ';
}
Get the width and height of the DOM
var owidth = getcss Tutorial (obj, ' width '), oheight = Getcss (obj, ' height ');
Decrements per dom (equal proportions)
var wcut = 10* (+owidth.replace (' px ', ')/+oheight.replace (' px ', '), hcut = 10;
Working with animation functions
var process = function (width,height) {
width = +width-wcut>0?+width-wcut:0;
Height = +height-hcut>0?+width-hcut:0;
Judge if it's done.
if (width!== 0 | | height!== 0) {
Obj.style.width = width+ ' px ';
Obj.style.height = height+ ' px ';

settimeout (function () {process (width,height);},speed);
}
else {
After the reduction, set the property to hidden and the width and height of the original DOM
Obj.style.display = ' None ';
Obj.style.width = Owidth;
Obj.style.height = Oheight;
if (FN) fn.call (obj);
}
}
Process (owidth.replace (' px ', '), Oheight.replace (' px ', '));
}

Display function

var show = function (OBJ,SPEED,FN) {

obj = $ (obj);

if (!speed) {
Obj.style.display = ' block ';
Return
}
else{
Speed = speed=== ' fast '? 20:speed=== ' normal '? 30:50;
Obj.style.overflow = ' hidden ';
}

var owidth = getcss (obj, ' width '). replace (' px ', '), oheight = Getcss (obj, ' height '). Replace (' px ', ');
var wadd = 10* (+owidth/+oheight), Hadd = 10;

Obj.style.width = 0+ ' px ';
Obj.style.height = 0+ ' px ';
Obj.style.display = ' block ';

var process = function (width,height) {
width = +owidth-width<wadd?+owidth:wadd+width;
Height = +oheight-height

if (width!== +owidth | | height!== +oheight) {
Obj.style.width = width+ ' px ';
Obj.style.height = height+ ' px ';

settimeout (function () {process (width,height);},speed);
}
else {
Obj.style.width = owidth+ ' px ';
Obj.style.height = oheight+ ' px ';
if (FN) fn.call (obj);
}
}
Process (0,0);
}

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.