Best JavaScript code snippet using wpt
projectSpaceView.js
Source:projectSpaceView.js
1/**2 * Created by tang on 2018/10/15.3 */4$(function(){5 //å·¥ç¨å表 é¼ æ æ¬åææ6 var projectList = $("#project-content");7 projectHover(projectList);8 function projectHover(main){9 main.on('mouseenter','.project-item__thumb',function(e){10 getIn($(this),e);11 }).on('mouseleave','.project-item__thumb',function(e){12 getOut($(this),e)13 });14 //æ¹å15 function getDirection(obj,e){16 var bleft=obj.offset().left;17 var btop=obj.offset().top;18 var li_w=obj.width();19 var li_h=obj.height();20 var evt=e||window.event;21 var x=evt.pageX-bleft;22 var y=evt.pageY-btop;23 x=Math.abs(x);24 y=Math.abs(y);25 if(x>li_w){26 x=li_w-(x-li_w);27 }28 var Alltan=Math.atan(li_h/li_w);//α29 var leftTan=Math.atan(y/x);//β30 var rightTan=Math.atan(y/(li_w-x));//θ31 if(0<=leftTan&&leftTan<=Alltan&&0<=rightTan&&rightTan<=Alltan){32 return 1;33 }else if(Alltan<=leftTan&&leftTan<=Math.asin(1)&&0<=rightTan&&rightTan<=Alltan){34 return 2;35 }else if(Alltan<=leftTan&&leftTan<=Math.asin(1)&&Alltan<=rightTan&&rightTan<=Math.asin(1)){36 return 3;37 }else if(0<=leftTan&&leftTan<=Alltan&&Alltan<=rightTan&&rightTan<=Math.asin(1)){38 return 4;39 }40 }41 //移å
¥42 function getIn(obj,e){43 var status=getDirection(obj,e);44 var li_w=obj.width();45 var that=obj.find('.project-item__hover-menu');46 var child_h=that.height();47 if(status===1){48 that.css({49 "left":0,50 "top":-child_h51 }).stop().animate({52 "top":053 },200)54 }else if(status===2){55 that.css({56 "left":-li_w,57 "top":058 }).stop().animate({59 "left":060 },200)61 }else if(status===3){62 that.css({63 "left":064 }).stop().animate({65 "top":066 },200)67 }else if(status===4){68 that.css({69 "left":li_w,70 "top":071 }).stop().animate({72 "left":073 },200)74 }75 }76 //移åº77 function getOut(obj,e){78 var status=getDirection(obj,e);79 var li_w=obj.width();80 var that=obj.find('.project-item__hover-menu');81 var child_h=that.height();82 if(status===1){83 that.stop().animate({84 "top":-child_h85 },200,function(){86 $(this).css({87 "left":0,88 "top":child_h89 })90 })91 }else if(status===2){92 that.stop().animate({93 "left":-li_w94 },200,function(){95 $(this).css({96 "left":0,97 "top":child_h98 })99 })100 }else if(status===3){101 that.css({102 "left":0103 }).stop().animate({104 "top":child_h105 },200)106 }else if(status===4){107 that.stop().animate({108 "left":li_w109 },200,function(){110 $(this).css({111 "left":0,112 "top":child_h113 })114 })115 }116 }117 }...
webvr-api-tests.ts
Source:webvr-api-tests.ts
1function fieldOfViewToProjectionMatrix(fov: VRFieldOfView, zNear: number, zFar: number) {2 var upTan = Math.tan(fov.upDegrees * Math.PI/180.0);3 var downTan = Math.tan(fov.downDegrees * Math.PI/180.0);4 var leftTan = Math.tan(fov.leftDegrees * Math.PI/180.0);5 var rightTan = Math.tan(fov.rightDegrees * Math.PI/180.0);6 var xScale = 2.0 / (leftTan + rightTan);7 var yScale = 2.0 / (upTan + downTan);8 var out = new Float32Array(16);9 out[0] = xScale;10 out[1] = 0.0;11 out[2] = 0.0;12 out[3] = 0.0;13 out[4] = 0.0;14 out[5] = yScale;15 out[6] = 0.0;16 out[7] = 0.0;17 out[8] = -((leftTan - rightTan) * xScale * 0.5);18 out[9] = ((upTan - downTan) * yScale * 0.5);19 out[10] = -(zNear + zFar) / (zFar - zNear);20 out[11] = -1.0;21 out[12] = 0.0;22 out[13] = 0.0;23 out[14] = -(2.0 * zFar * zNear) / (zFar - zNear);24 out[15] = 0.0;25 return out;26}27var hmd: VRDisplay;28var leftEyeParams = hmd.getEyeParameters("left");29var rightEyeParams = hmd.getEyeParameters("right");30var leftEyeRect = { width: leftEyeParams.renderWidth, height: leftEyeParams.renderHeight };31var rightEyeRect = { width: rightEyeParams.renderWidth, height: rightEyeParams.renderHeight };32var canvas: HTMLCanvasElement;33canvas.width = rightEyeParams.renderWidth * 2;34canvas.height = Math.max(leftEyeRect.height, rightEyeRect.height);35var gHMD: VRDisplay;36navigator.getVRDisplays().then(function(devices) {37 for (var i = 0; i < devices.length; ++i) {38 if (devices[i] instanceof VRDisplay) {39 gHMD = devices[i];40 break;41 }42 }...
Using AI Code Generation
1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getTesters(function(err, data) {4 if (err) return console.log(err);5 console.log(data);6});7var WebPageTest = require('webpagetest');8var wpt = new WebPageTest('www.webpagetest.org');9wpt.getTesters(function(err, data) {10 if (err) return console.log(err);11 console.log(data);12});13 throw err;14 at Function.Module._resolveFilename (module.js:336:15)15 at Function.Module._load (module.js:278:25)16 at Module.require (module.js:365:17)17 at require (module.js:384:17)18 at Object.<anonymous> (C:\Users\user\Documents\Node\test\test.js:1:14)19 at Module._compile (module.js:460:26)20 at Object.Module._extensions..js (module.js:478:10)21 at Module.load (module.js:355:32)22 at Function.Module._load (module.js:310:12)23 at Function.Module.runMain (module.js:501:10)24var WebPageTest = require('webpagetest');25var wpt = new WebPageTest('www.webpagetest.org');26wpt.getTesters(function(err, data) {27 if (err) return console.log(err);28 console.log(data);29});30 throw err;31 at Function.Module._resolveFilename (module.js:336:15)32 at Function.Module._load (module.js:278:25)33 at Module.require (module.js
Using AI Code Generation
1var wpt = require('wpt');2var rightTan = wpt.rightTan;3var tan = rightTan(3);4console.log(tan);5var wpt = require('wpt');6var rightTan = wpt.rightTan;7var tan = rightTan(3);8console.log(tan);9var wpt = require('wpt');10var rightTan = wpt.rightTan;11var tan = rightTan(3);12console.log(tan);13var wpt = require('wpt');14var rightTan = wpt.rightTan;15var tan = rightTan(3);16console.log(tan);17var wpt = require('wpt');18var rightTan = wpt.rightTan;19var tan = rightTan(3);20console.log(tan);21var wpt = require('wpt');22var rightTan = wpt.rightTan;23var tan = rightTan(3);24console.log(tan);25var wpt = require('wpt');26var rightTan = wpt.rightTan;27var tan = rightTan(3);28console.log(tan);29var wpt = require('wpt');30var rightTan = wpt.rightTan;31var tan = rightTan(3);32console.log(tan);33var wpt = require('wpt');34var rightTan = wpt.rightTan;35var tan = rightTan(3);36console.log(tan);37var wpt = require('wpt');38var rightTan = wpt.rightTan;39var tan = rightTan(3);40console.log(tan);41var wpt = require('w
Using AI Code Generation
1var wpt = new Waypoint();2var tan = wpt.rightTan();3tan = wpt.leftTan();4var wpt = new Waypoint();5var tan = wpt.rightTan();6tan = wpt.leftTan();7var wpt = new Waypoint();8var tan = wpt.rightTan();9tan = wpt.leftTan();10var wpt = new Waypoint();11var tan = wpt.rightTan();12tan = wpt.leftTan();13var wpt = new Waypoint();14var tan = wpt.rightTan();15tan = wpt.leftTan();16var wpt = new Waypoint();17var tan = wpt.rightTan();18tan = wpt.leftTan();19var wpt = new Waypoint();20var tan = wpt.rightTan();21tan = wpt.leftTan();22var wpt = new Waypoint();23var tan = wpt.rightTan();24tan = wpt.leftTan();25var wpt = new Waypoint();26var tan = wpt.rightTan();27tan = wpt.leftTan();28var wpt = new Waypoint();29var tan = wpt.rightTan();30tan = wpt.leftTan();31var wpt = new Waypoint();32var tan = wpt.rightTan();33tan = wpt.leftTan();34var wpt = new Waypoint();35var tan = wpt.rightTan();36tan = wpt.leftTan();
Using AI Code Generation
1function getRightTan() {2 var wpt = new Waypoint();3 var rightTan = wpt.rightTan;4}5function getRightTan() {6 var wpt = new Waypoint();7 var rightTan = wpt.rightTan;8}9function getRightTan() {10 var wpt = new Waypoint();11 var rightTan = wpt.rightTan;12}13function getRightTan() {14 var wpt = new Waypoint();15 var rightTan = wpt.rightTan;16}17function getRightTan() {18 var wpt = new Waypoint();19 var rightTan = wpt.rightTan;20}21function getRightTan() {22 var wpt = new Waypoint();23 var rightTan = wpt.rightTan;24}25function getRightTan() {26 var wpt = new Waypoint();27 var rightTan = wpt.rightTan;28}29function getRightTan() {30 var wpt = new Waypoint();31 var rightTan = wpt.rightTan;32}33function getRightTan() {34 var wpt = new Waypoint();35 var rightTan = wpt.rightTan;36}37function getRightTan() {38 var wpt = new Waypoint();39 var rightTan = wpt.rightTan;40}41function getRightTan() {42 var wpt = new Waypoint();43 var rightTan = wpt.rightTan;44}45function getRightTan() {46 var wpt = new Waypoint();47 var rightTan = wpt.rightTan;
Using AI Code Generation
1var wpt = require('./wpt.js');2var wptObj = new wpt();3wptObj.rightTan(2,2);4var wpt = function() {5 this.rightTan = function(a,b) {6 console.log(a/b);7 }8}9module.exports = wpt;10function pluralize(number, word) {11 if (number === 1) {12 return number + " " + word;13 } else {14 return number + " " + word + "s";15 }16}17console.log(pluralize(1, "dog"));18console.log(pluralize(2, "dog"));19function countVowels(string) {20 var vowels = ["a", "e", "i", "o", "u"];21 var count = 0;22 for (var i = 0; i < string.length; i++) {23 if (vowels.indexOf(string[i]) !== -1) {24 count++;25 }26 }27 return count;28}29function countConsonants(string) {30 var consonants = ["b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z"];31 var count = 0;32 for (var i = 0; i < string.length;
Using AI Code Generation
1var wpt = new Waypoint(49.0, -123.0, 0);2var wpt2 = new Waypoint(50.0, -124.0, 0);3var right = wpt.rightTan(wpt2);4console.log("Right tangent: " + right);5I'm not familiar with node.js, but I'm guessing that the problem is that it doesn't allow you to use global variables. So, instead of using wpt as a global variable, you'll have to pass it as a parameter to the rightTan() function. Something like:6var Waypoint = function(lat, lon, alt) {7 this.lat = lat;8 this.lon = lon;9 this.alt = alt;10 this.rightTan = function(wpt) {11 return right;12 };13};14var wpt = new Waypoint(49.0, -123.0,
Using AI Code Generation
1var path = new Path();2path.add(100, 100);3path.add(200, 200);4path.add(100, 200);5path.closed = true;6var rightTan = path.getTangentAt(0).rotate(90);7var line = new Path.Line(path.firstSegment.point, path.firstSegment.point + rightTan * 100);8line.strokeColor = 'red';
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.6e0c7a2b1e8b9c9d0a0c7ed3eb3f8e7a');3 if (err) return console.error(err);4 console.log(data);5 wpt.getTestResults(data.data.testId, function(err, data) {6 if (err) return console.error(err);7 console.log(data.data.median.firstView);8 });9});10{statusCode: 200, statusText: "Ok", data: {…}, responseTime: 9.452}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!