Javascript3d by-investigation product presentation (simplified core) _ javascript skills-js tutorial

Source: Internet
Author: User
This article describes how to display javascript-implemented 3d object-based detection products. For more information, see 3d object-based detection image materials.

Javascript code

The Code is as follows:


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 Step ++;
If (step> = lth-1 ){
Step = 0
}
} Else {
Step --
If (step <= 0 ){
Step = lth-1;
}
}
First = x;
Document. querySelectorAll ('# tobj img') [step]. style. display = 'block'
}
})
Window. addEventListener ('touchend', function (e ){
E. preventDefault ();
Step = step;
})


Simplified Core

The Code is as follows:


If (Math. abs (x-first)> 10 ){
Document. querySelectorAll ('# tobj img') [step]. style. display = 'none'
If (x Step ++;
If (step> = lth-1 ){
Step = 0
}
} Else {
Step --
If (step <= 0 ){
Step = lth-1;
}
}
First = x;
Document. querySelectorAll ('# tobj img') [step]. style. display = 'block'
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.