//图片手势放大
varreqAnimationFrame = (function() {
returnwindow[Hammer.prefixed(window,'requestAnimationFrame')] ||function(callback) {
window.setTimeout(callback, 1000 / 60);
};
})();
varel = $('img');
varticking =false;
vartransform;
varinitScale = 1;
var_eImg ='';
for(varm = 0; m css({ 'transform': value }, { '-webkit-transform': value });
}
ticking =false;
}
functionrequestElementUpdate() {
if(!ticking) {
reqAnimationFrame(updateElementTransform);
ticking =true;
}
}
functiononPan(ev) {
el.removeClass('animate');
transform.translate = {
x: ev.deltaX,
y: ev.deltaY
};
}
functiononPinch(ev) {
if(ev.type =='pinchstart') {
initScale = transform.scale || 1;
}
el.removeClass('animate');
transform.scale = initScale * ev.scale;
requestElementUpdate();
_eImg = ev.target;
return_eImg;
}
functiononSwipe(ev) {
varangle = 10;
transform.ry = (ev.direction & Hammer.DIRECTION_HORIZONTAL) ? 1 : 0;
transform.rx = (ev.direction & Hammer.DIRECTION_VERTICAL) ? 1 : 0;
transform.angle = (ev.direction & (Hammer.DIRECTION_RIGHT | Hammer.DIRECTION_UP)) ? angle : -angle;
requestElementUpdate();
_eImg = ev.target;
return_eImg;
}
resetElement();