jquery图片延迟加载插件(2)
一、使用的文件
<script type="text/javascript" src="<%: Url.Content("~/Content/js/klass.min.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Content/js/photoswipe-3.0.5.js")%>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Content/js/zepto.js") %>"></script>
二、js代码
<script type="text/javascript">
var curnumber = 0;
document.addEventListener('DOMContentLoaded', function () {
var myPhotoSwipe = Code.PhotoSwipe.attach(window.document.querySelectorAll('#Gallery a'), { allowUserZoom: true, preventHide: true, captionAndToolbarHide: true, loop: false, doubleTapZoomLevel: 3 });
myPhotoSwipe.show(curnumber);
orientationchange();
}, false);
var n = 0;
var hide_other = 0;
var flag = 0;
document.addEventListener('touchstart', function (ev) {
flag = 0;
});
document.addEventListener('touchmove', function (ev) {
flag = 1;
});
document.addEventListener('touchend', function (ev) {
if (ev.target.getAttribute("class") == "ps-uilayer" && flag == 0) {
n++;
var timer = setTimeout("callBack();", 300);
if (n == 2) {
clearTimeout(timer);
}
}
});
function callBack() {
if (n == 1) {
hideother();
}
n = 0;
}
function hideother() {
if (hide_other == 0) {
$('#album_top').hide();
$('#album_foot').hide();
hide_other = 1;
} else {
$('#album_top').show();
$('#album_foot').show();
hide_other = 0;
}
}
var evt = "onorientationchange" in window ? "orientationchange" : "resize";
window.addEventListener(evt, function () { orientationchange(); }, false);
//判断横屏还是宽屏
function orientationchange() {
if (window.innerWidth >= window.innerHeight) {
//横屏
hide_other = 0;
hideother();
}
else {
//竖屏
hide_other = 1;
hideother();
}
}
</script>

浙公网安备 33010602011771号