DJ

var reelup = document.getElementById('reelup');
var reeldown = document.getElementById('reeldown');
var reelplay2 = document.getElementById('reelplay2');
var frontpage = parseInt(reelplay2.getAttribute('data-frames'));
var pageList = reelplay2.getAttribute('data-images').split(',');
var pagelen = pageList.length;
var Task;

var addListener = function(dom, eventName, callback, options) {
options = options || {};
if (dom.attachEvent) {
dom.attachEvent('on' + eventName, callback);
} else {
dom.addEventListener(eventName, callback, options.capture || false);
}
}
addListener(reelup,'mousedown',fun1);
addListener(reeldown,'mousedown',fun1);
function fun1(){


if(frontpage==pagelen-1){
Task = setInterval(function() {
pageup(frontpage);
}, 40);
}else{
Task = setInterval(function() {
pagedown(frontpage);
}, 40);
}

}

function pagedown(localfrontpage){
reelplay2.setAttribute('src',pageList[++frontpage]);
//console.log(frontpage);
if(frontpage==pagelen-1){
clearInterval(Task);
Task = null;
}

}

function pageup(localfrontpage){
//console.log(frontpage);
reelplay2.setAttribute('src',pageList[--frontpage]);
if(frontpage==0){
clearInterval(Task);
Task = null;
}

}

posted @ 2014-03-04 17:02  无与hebe  阅读(137)  评论(1编辑  收藏  举报