123456789101112131415161718192021222324252627282930313233343536373839404142 |
-
- var OSHelper = {
- isPC: undefined,
- touchStart: undefined,
- touchMove: undefined,
- touchEnd: undefined,
- orbitCtlDistanceMultiple: undefined,
- windowWidthDefault: undefined,
- init: function () {
- this.isPC = this.isPCOS();
- this.touchStart = this.isPC ? 'mousedown' : 'touchstart';
- this.touchMove = this.isPC ? 'mousemove' : 'touchmove';
- this.touchEnd = this.isPC ? 'mouseup' : 'touchend';
- this.orbitCtlDistanceMultiple = this.isPC ? 3 : 2;
- this.windowWidthDefault = this.isPC ? 1100 : 600;
- },
- isPCOS: function () {
- var userAgentInfo = navigator.userAgent;
- var Agents = ["Android", "iPhone",
- "SymbianOS", "Windows Phone",
- "iPad", "iPod"];
- var result = true;
- for (var v = 0; v < Agents.length; v++) {
- if (userAgentInfo.indexOf(Agents[v]) > 0) {
- result = false;
- break;
- }
- }
- return result;
- },
- clientX: function (event) {
- return this.isPC ? event.clientX : event.targetTouches[0].clientX;
- },
- clientY: function (event) {
- return this.isPC ? event.clientY : event.targetTouches[0].clientY;
- },
- convertCefParameter: function (inputData) {
- return this.isPC ? inputData : JSON.stringify(inputData);
- }
- };
|