-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwyp-defined.js
33 lines (33 loc) · 1.12 KB
/
wyp-defined.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// 计算rem进行计算
!(function (doc, win) {
"use strict";
if(window.location.href.indexOf("jshop.jd.com")>0){return false};
var fontScale;
fontScale = function(){
var innerWidth = win.innerWidth;
if (!innerWidth) {
return false;
}
// 不用计算的rem 640
// doc.documentElement.style.fontSize = (50 * innerWidth / 320) + 'px';
// 750
doc.documentElement.style.fontSize = (50 * innerWidth / 375) + 'px';
};
fontScale();
win.addEventListener('resize', fontScale, false);
})(document, window);
// 限制懒加载
window.addEventListener("load",function(){
var aImg=document.querySelectorAll(".wrap img"),
src;
if(window.location.href.indexOf("sale.jd.com")!=-1){
for(var i=0;i < aImg.length;i++){
(function(index){
if(aImg[index].getAttribute("data-srcset")){
src=aImg[index].getAttribute("data-srcset");
aImg[index].src=src;
}
})(i)
};
}
},false);