init: function(){
this.elem = document.getElementById("focusphoto");
this.photoWidth = this.elem.scrollWidth;
this.photoHeight = this.elem.scrollHeight;
this.zoom = 1.2; // 设置基本参数
this.count = 0;
this.cpu = 1;
},
action: function(x){
if(x === 0){
this.cpu = 1;
this.count = 0;
}else{
this.count += x; // 添加记录
this.cpu = Math.pow(this.zoom, this.count); // 任意次幂运算
};
this.elem.style.width = this.photoWidth * this.cpu +"px";
this.elem.style.height = this.photoHeight * this.cpu +"px";
}
};
// 启动放大缩小效果 用onload方式加载,防止第一次点击获取不到图片的宽高
window.onload = function(){PhotoSize.init()};
建议最好采用onload方式引用,可以准确读到初始图片的大小
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
Copyright © 2019- axer.cn 版权所有 湘ICP备2023022495号-12
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务