Материал трехмерного исследования картинка
JavaScript Code
Кода -копия выглядит следующим образом:
<span style = "Белое пространство: pre"> </span> var step = 0;
var First = 0;
var lth = document.queryselectorall ('#tobj img'). Length;
window.addeventListener ('touchStart', function (e) {
e.preventdefault ();
first = e.touches [0] .pagex;
})
window.addeventlistener ('touchmove', function (e) {
e.preventdefault ();
var x = e.pagex || e.touches [0] .pagex;
document.getElementbyId ('outs'). innerHtml = step;
if (math.abs (x - first)> 10) {
document.queryselectorall ('#tobj img') [step] .style.display = 'none'
if (x <первое) {
шаг ++;
if (step> = lth-1) {
Шаг = 0
}
}еще{
шаг--
if (step <= 0) {
step = lth-1;
}
}
First = x;
document.queryselectorall ('#tobj img') [step] .style.display = 'block'
}
})
window.addeventlistener ('touchend', function (e) {
e.preventdefault ();
шаг = шаг;
})
Основная оптимизация
Кода -копия выглядит следующим образом:
if (math.abs (x - first)> 10) {
document.queryselectorall ('#tobj img') [step] .style.display = 'none'
if (x <первое) {
шаг ++;
if (step> = lth-1) {
Шаг = 0
}
}еще{
шаг--
if (step <= 0) {
step = lth-1;
}
}
First = x;
document.queryselectorall ('#tobj img') [step] .style.display = 'block'
}