//interval变量
var inl = [];
//原始透明度
var opa = 100;
//判断浏览器
var ie = navigator.appName == "Microsoft Internet Explorer" ? "Microsoft Internet Explorer" : "";
//缩小和打开按纽
function gogo() {
speed = 50;
var mode;
//利用方块的display来判定是否缩小或放大
if(!$('tmp').style.display) {
mode = "-";
//display是正常的话设置interval缩小
inl['suotu'] = setInterval("suodi('-')", 10);
}else {
mode = "+";
//display是none的话先把display改回去正常,再设置interval放大
$('tmp').style.display = "";
inl['suotu'] = setInterval("suodi('+')", 10);
}
clearInterval(inl['dcdr']);
inl['dcdr'] = setInterval("dcdr('" + mode + "')", 10);
}
//淡出淡入
function dcdr(op) {
//获取透明度
opa = define(op, opa, 4, 0, 100);
//更新透明度
ie ? $('tmp').style.filter = "alpha(opacity=" + opa + ")" : $('tmp').style.opacity = opa / 100;
//如果透明度小于等于0或大于等于100
if(opa <= 0 || opa >= 100) {
//停止interval
clearInterval(inl['dcdr']);
}
}
function define(id, a, b, a2, a3) {
if(id == "-") {
a -= b;
if(a <= a2) {
a = a2;
}
}else {
a += b;
if(a >= a3) {
a = a3;
}
}
return a;
}
//缩小或放大
function suodi(opt) {
//速度大于1的话继续除以s,否则等于1
speed = speed > 1 ? speed * 0.862 : 1;
//获取高度
var hw = define(opt, $('tmp').clientHeight, speed, speed, 300);
//设定高度和宽度
$('tmp').style.height = hw + "px";
$('tmp').style.width = hw + "px";
//假如方块的高度小于速度
if($('tmp').clientHeight <= speed) {
//隐藏方块
$('tmp').style.display = "none";
//按钮名字改为"打开"
$('anniu').value = "打开";
//关闭interval
clearInterval(inl['suotu']);
}else if($('tmp').clientWidth >= 300) {
//按钮名字改为"缩小"
$('anniu').value = "缩小";
//关闭interval
clearInterval(inl['suotu']);
}
}
//简化getElementById为$
var $ = function($) {
return document.getElementById($);
}
//interval变量
var inl = [];
//原始透明度
var opa = 100;
//判断浏览器
var ie = navigator.appName == "Microsoft Internet Explorer" ? "Microsoft Internet Explorer" : "";
//缩小和打开按纽
function gogo() {
speed = 50;
var mode;
//利用方块的display来判定是否缩小或放大
if(!$('tmp').style.display) {
mode = "-";
//display是正常的话设置interval缩小
inl['suotu'] = setInterval("suodi('-')", 10);
}else {
mode = "+";
//display是none的话先把display改回去正常,再设置interval放大
$('tmp').style.display = "";
inl['suotu'] = setInterval("suodi('+')", 10);
}
clearInterval(inl['dcdr']);
inl['dcdr'] = setInterval("dcdr('" + mode + "')", 10);
}
//淡出淡入
function dcdr(op) {
//获取透明度
opa = define(op, opa, 4, 0, 100);
//更新透明度
ie ? $('tmp').style.filter = "alpha(opacity=" + opa + ")" : $('tmp').style.opacity = opa / 100;
//如果透明度小于等于0或大于等于100
if(opa <= 0 || opa >= 100) {
//停止interval
clearInterval(inl['dcdr']);
}
}
function define(id, a, b, a2, a3) {
if(id == "-") {
a -= b;
if(a <= a2) {
a = a2;
}
}else {
a += b;
if(a >= a3) {
a = a3;
}
}
return a;
}
//缩小或放大
function suodi(opt) {
//速度大于1的话继续除以s,否则等于1
speed = speed > 1 ? speed * 0.862 : 1;
//获取高度
var hw = define(opt, $('tmp').clientHeight, speed, speed, 300);
//设定高度和宽度
$('tmp').style.height = hw + "px";
$('tmp').style.width = hw + "px";
//假如方块的高度小于速度
if($('tmp').clientHeight <= speed) {
//隐藏方块
$('tmp').style.display = "none";
//按钮名字改为"打开"
$('anniu').value = "打开";
//关闭interval
clearInterval(inl['suotu']);
}else if($('tmp').clientWidth >= 300) {
//按钮名字改为"缩小"
$('anniu').value = "缩小";
//关闭interval
clearInterval(inl['suotu']);
}
}
//简化getElementById为$
var $ = function($) {
return document.getElementById($);
}
<body style="margin:0; padding:100px 150px" style="margin:0; padding:100px 150px">
<table style="border:1px solid #ccc" style="border:1px solid #ccc">
<tr>
<td><div style="position:absolute; font-family:'微软雅黑'; font-size:13px" style="position:absolute; font-family:'微软雅黑'; font-size:13px"> 演示</div><div id="tmp" style="height:300px; width:300px; background:black"></div></td>
</tr>
<tr>
<td align="center" style="padding-top:20px" style="padding-top:20px">
<input id="anniu" type="button" value="缩小" style="font-family:'微软雅黑'; font-size:12px; font-weight:bold; border:1px solid #ccc" style="font-family:'微软雅黑'; font-size:12px; font-weight:bold; border:1px solid #ccc" onfocus="this.blur()" onclick="gogo()"/>
</td>
</tr>
</table>
</body>
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
var inl = [];
//原始透明度
var opa = 100;
//判断浏览器
var ie = navigator.appName == "Microsoft Internet Explorer" ? "Microsoft Internet Explorer" : "";
//缩小和打开按纽
function gogo() {
speed = 50;
var mode;
//利用方块的display来判定是否缩小或放大
if(!$('tmp').style.display) {
mode = "-";
//display是正常的话设置interval缩小
inl['suotu'] = setInterval("suodi('-')", 10);
}else {
mode = "+";
//display是none的话先把display改回去正常,再设置interval放大
$('tmp').style.display = "";
inl['suotu'] = setInterval("suodi('+')", 10);
}
clearInterval(inl['dcdr']);
inl['dcdr'] = setInterval("dcdr('" + mode + "')", 10);
}
//淡出淡入
function dcdr(op) {
//获取透明度
opa = define(op, opa, 4, 0, 100);
//更新透明度
ie ? $('tmp').style.filter = "alpha(opacity=" + opa + ")" : $('tmp').style.opacity = opa / 100;
//如果透明度小于等于0或大于等于100
if(opa <= 0 || opa >= 100) {
//停止interval
clearInterval(inl['dcdr']);
}
}
function define(id, a, b, a2, a3) {
if(id == "-") {
a -= b;
if(a <= a2) {
a = a2;
}
}else {
a += b;
if(a >= a3) {
a = a3;
}
}
return a;
}
//缩小或放大
function suodi(opt) {
//速度大于1的话继续除以s,否则等于1
speed = speed > 1 ? speed * 0.862 : 1;
//获取高度
var hw = define(opt, $('tmp').clientHeight, speed, speed, 300);
//设定高度和宽度
$('tmp').style.height = hw + "px";
$('tmp').style.width = hw + "px";
//假如方块的高度小于速度
if($('tmp').clientHeight <= speed) {
//隐藏方块
$('tmp').style.display = "none";
//按钮名字改为"打开"
$('anniu').value = "打开";
//关闭interval
clearInterval(inl['suotu']);
}else if($('tmp').clientWidth >= 300) {
//按钮名字改为"缩小"
$('anniu').value = "缩小";
//关闭interval
clearInterval(inl['suotu']);
}
}
//简化getElementById为$
var $ = function($) {
return document.getElementById($);
}
//interval变量
var inl = [];
//原始透明度
var opa = 100;
//判断浏览器
var ie = navigator.appName == "Microsoft Internet Explorer" ? "Microsoft Internet Explorer" : "";
//缩小和打开按纽
function gogo() {
speed = 50;
var mode;
//利用方块的display来判定是否缩小或放大
if(!$('tmp').style.display) {
mode = "-";
//display是正常的话设置interval缩小
inl['suotu'] = setInterval("suodi('-')", 10);
}else {
mode = "+";
//display是none的话先把display改回去正常,再设置interval放大
$('tmp').style.display = "";
inl['suotu'] = setInterval("suodi('+')", 10);
}
clearInterval(inl['dcdr']);
inl['dcdr'] = setInterval("dcdr('" + mode + "')", 10);
}
//淡出淡入
function dcdr(op) {
//获取透明度
opa = define(op, opa, 4, 0, 100);
//更新透明度
ie ? $('tmp').style.filter = "alpha(opacity=" + opa + ")" : $('tmp').style.opacity = opa / 100;
//如果透明度小于等于0或大于等于100
if(opa <= 0 || opa >= 100) {
//停止interval
clearInterval(inl['dcdr']);
}
}
function define(id, a, b, a2, a3) {
if(id == "-") {
a -= b;
if(a <= a2) {
a = a2;
}
}else {
a += b;
if(a >= a3) {
a = a3;
}
}
return a;
}
//缩小或放大
function suodi(opt) {
//速度大于1的话继续除以s,否则等于1
speed = speed > 1 ? speed * 0.862 : 1;
//获取高度
var hw = define(opt, $('tmp').clientHeight, speed, speed, 300);
//设定高度和宽度
$('tmp').style.height = hw + "px";
$('tmp').style.width = hw + "px";
//假如方块的高度小于速度
if($('tmp').clientHeight <= speed) {
//隐藏方块
$('tmp').style.display = "none";
//按钮名字改为"打开"
$('anniu').value = "打开";
//关闭interval
clearInterval(inl['suotu']);
}else if($('tmp').clientWidth >= 300) {
//按钮名字改为"缩小"
$('anniu').value = "缩小";
//关闭interval
clearInterval(inl['suotu']);
}
}
//简化getElementById为$
var $ = function($) {
return document.getElementById($);
}
<body style="margin:0; padding:100px 150px" style="margin:0; padding:100px 150px">
<table style="border:1px solid #ccc" style="border:1px solid #ccc">
<tr>
<td><div style="position:absolute; font-family:'微软雅黑'; font-size:13px" style="position:absolute; font-family:'微软雅黑'; font-size:13px"> 演示</div><div id="tmp" style="height:300px; width:300px; background:black"></div></td>
</tr>
<tr>
<td align="center" style="padding-top:20px" style="padding-top:20px">
<input id="anniu" type="button" value="缩小" style="font-family:'微软雅黑'; font-size:12px; font-weight:bold; border:1px solid #ccc" style="font-family:'微软雅黑'; font-size:12px; font-weight:bold; border:1px solid #ccc" onfocus="this.blur()" onclick="gogo()"/>
</td>
</tr>
</table>
</body>
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
标签:
Javascript,动态伸缩
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“Javascript动态伸缩+淡出淡入”评论...
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。