How to use _end method in Cypress

Best JavaScript code snippet using cypress

CnxShape.js.js

Source:CnxShape.js.js Github

copy

Full Screen

1/**2 * Created by Sergey.Luzyanin on 4/25/2017.3 */4(function(undefined){5 var CONNECTOR_MARGIN = 6.35;6 /**7 * @constructor8 * */9 function ConnectionParams(){10 this.bounds = new AscFormat.CGraphicBounds(0, 0, 0, 0);11 this.dir = AscFormat.CARD_DIRECTION_E;12 this.x = 0;13 this.y = 0;14 this.idx = 0;15 }16 ConnectionParams.prototype.copy = function(){17 var _c = new ConnectionParams();18 _c.bounds.fromOther(this.bounds);19 _c.dir = this.dir;20 _c.x = this.x;21 _c.y = this.y;22 _c.idx = this.idx;23 return _c;24 };25 ConnectionParams.prototype.transform = function(oTransform){26 this.bounds.transform(oTransform);27 //this.dir = AscFormat.CARD_DIRECTION_E;28 var _x = oTransform.TransformPointX(this.x, this.y);29 var _y = oTransform.TransformPointY(this.x, this.y);30 this.x = _x;31 this.y = _y;32 };33 function fCalculateSpPr(begin, end, sPreset, penW){34 return AscFormat.ExecuteNoHistory(function(){35 var oSpPr = new AscFormat.CSpPr();36 var oXfrm = new AscFormat.CXfrm();37 oSpPr.setXfrm(oXfrm);38 oXfrm.setParent(oSpPr);39 var _begin = begin.copy();40 var _end = end.copy();41 var fAngle = 0;42 if(!penW){43 penW = 12700;44 }45 switch(begin.dir){46 case AscFormat.CARD_DIRECTION_N:{47 fAngle = Math.PI/2;48 switch(_end.dir){49 case AscFormat.CARD_DIRECTION_N:{50 _end.dir = AscFormat.CARD_DIRECTION_E;51 break;52 }53 case AscFormat.CARD_DIRECTION_S:{54 _end.dir = AscFormat.CARD_DIRECTION_W;55 break;56 }57 case AscFormat.CARD_DIRECTION_W:{58 _end.dir = AscFormat.CARD_DIRECTION_N;59 break;60 }61 case AscFormat.CARD_DIRECTION_E:{62 _end.dir = AscFormat.CARD_DIRECTION_S;63 break;64 }65 }66 break;67 }68 case AscFormat.CARD_DIRECTION_S:{69 fAngle = -Math.PI/2;70 switch(_end.dir){71 case AscFormat.CARD_DIRECTION_N:{72 _end.dir = AscFormat.CARD_DIRECTION_W;73 break;74 }75 case AscFormat.CARD_DIRECTION_S:{76 _end.dir = AscFormat.CARD_DIRECTION_E;77 break;78 }79 case AscFormat.CARD_DIRECTION_W:{80 _end.dir = AscFormat.CARD_DIRECTION_S;81 break;82 }83 case AscFormat.CARD_DIRECTION_E:{84 _end.dir = AscFormat.CARD_DIRECTION_N;85 break;86 }87 }88 break;89 }90 case AscFormat.CARD_DIRECTION_W:{91 fAngle = Math.PI;92 switch(_end.dir){93 case AscFormat.CARD_DIRECTION_N:{94 _end.dir = AscFormat.CARD_DIRECTION_S;95 break;96 }97 case AscFormat.CARD_DIRECTION_S:{98 _end.dir = AscFormat.CARD_DIRECTION_N;99 break;100 }101 case AscFormat.CARD_DIRECTION_W:{102 _end.dir = AscFormat.CARD_DIRECTION_E;103 break;104 }105 case AscFormat.CARD_DIRECTION_E:{106 _end.dir = AscFormat.CARD_DIRECTION_W;107 break;108 }109 }110 break;111 }112 default:{113 //East is default direction114 fAngle = 0;115 break;116 }117 }118 var oTransform = new AscCommon.CMatrix();119 AscCommon.global_MatrixTransformer.RotateRadAppend(oTransform, -fAngle);120 _begin.transform(oTransform);121 _end.transform(oTransform);122 var extX = Math.max(penW/36000.0, Math.abs(_end.x - _begin.x));123 var extY = Math.max(penW/36000.0, Math.abs(_end.y - _begin.y));124 var flipV = false;125 var flipH = false;126 var rot = 0;127 var oMapAdj = {};128 if(sPreset === "line" ||129 sPreset.indexOf("straightConnector") > -1){130 flipH = (_begin.x > _end.x);131 flipV = (_begin.y > _end.y);132 }133 else{134 var sPrefix = "bentConnector";135 if(sPreset.indexOf("curvedConnector") > -1){136 sPrefix = "curvedConnector";137 }138 //returns "bentConnector" by default139 switch(_end.dir){140 case AscFormat.CARD_DIRECTION_N:{141 if(_end.bounds.l > _begin.bounds.r){142 if(_end.bounds.t < _begin.y){143 if(_end.y <= _begin.y){144 sPreset = "4";145 flipV = true;146 oMapAdj["adj1"] = (100000*(((_begin.bounds.r + _end.bounds.l)/2 - _begin.x)/extX) + 0.5) >> 0;147 oMapAdj["adj2"] = (100000*(_begin.y - (_end.bounds.t - CONNECTOR_MARGIN))/extY + 0.5) >> 0;148 }149 else{150 sPreset = "4";151 oMapAdj["adj1"] = (100000*(((_begin.bounds.r + _end.bounds.l)/2 - _begin.x)/extX) + 0.5) >> 0;152 oMapAdj["adj2"] = (-100000*( ( _begin.y - (_end.bounds.t - CONNECTOR_MARGIN) )/extY) + 0.5) >> 0;153 }154 }155 else{156 sPreset = "2";157 }158 }159 else{160 if(_end.bounds.t > _begin.bounds.b){161 if(_end.x < _begin.x){162 sPreset = "4";163 flipH = true;164 oMapAdj["adj1"] = -((100000*(_begin.bounds.r + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);165 oMapAdj["adj2"] = (100000*((_end.bounds.t + _begin.bounds.b)/2.0 - _begin.y)/extY) >> 0;166 }167 else{168 sPreset = "2";169 }170 }171 else if(_end.bounds.b < _begin.bounds.t){172 if(_end.x < _begin.x){173 sPreset = "4";174 flipH = true;175 flipV = true;176 oMapAdj["adj1"] = -((100000*(_begin.bounds.r + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);177 oMapAdj["adj2"] = (100000*(_begin.y - (_end.bounds.t - CONNECTOR_MARGIN))/extY + 0.5) >> 0;178 }179 else{180 sPreset = "4";181 flipV = true;182 oMapAdj["adj1"] = (100000*(Math.max(_begin.bounds.r, _end.bounds.r) + CONNECTOR_MARGIN - _begin.x)/extX) >> 0;183 oMapAdj["adj2"] = (100000*(_begin.y - (_end.bounds.t - CONNECTOR_MARGIN))/extY + 0.5) >> 0;184 }185 }186 else{187 if(_end.y < _begin.y){188 if(_end.x < _begin.x){189 sPreset = "4";190 flipH = true;191 flipV = true;192 oMapAdj["adj1"] = -((100000*(_begin.bounds.r + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);193 oMapAdj["adj2"] = (100000*(_begin.y - (_end.bounds.t - CONNECTOR_MARGIN))/extY + 0.5) >> 0;194 }195 else {196 sPreset = "4";197 flipV = true;198 oMapAdj["adj1"] = (100000*(Math.max(_begin.bounds.r, _end.bounds.r) + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0;199 oMapAdj["adj2"] = (100000*(_begin.y - (_end.bounds.t - CONNECTOR_MARGIN))/extY + 0.5) >> 0;200 }201 }202 else{203 if(_end.x > _begin.x){204 sPreset = "2";205 }206 else{207 sPreset = "4";208 flipH = true;209 oMapAdj["adj1"] = -(100000*(Math.max(_begin.bounds.r, _end.bounds.r) + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0;210 oMapAdj["adj2"] = -((100000*(_begin.y - (Math.min(_begin.bounds.t, _end.bounds.t) - CONNECTOR_MARGIN))/extY + 0.5) >> 0);211 }212 }213 }214 }215 break;216 }217 case AscFormat.CARD_DIRECTION_S:{218 if(_end.bounds.l > _begin.bounds.r){219 if(_end.bounds.b < _begin.y){220 sPreset = "2";221 flipV = true;222 }223 else{224 if(_end.y < _begin.y){225 sPreset = "4";226 flipV = true;227 oMapAdj["adj2"] = -((100000*((_end.bounds.b + CONNECTOR_MARGIN - _end.y)/extY) + 0.5) >> 0);228 oMapAdj["adj1"] = ((100000*(((_begin.bounds.r + _end.bounds.l)/2 - _begin.x))/extX) + 0.5) >> 0;229 }230 else{231 sPreset = "4";232 oMapAdj["adj1"] = (100000*(((_begin.bounds.r + _end.bounds.l)/2.0 - _begin.x)/extX) + 0.5) >> 0;233 oMapAdj["adj2"] = 100000 + ((100000*((_end.bounds.b + CONNECTOR_MARGIN - _end.y)/extY) + 0.5) >> 0);234 }235 }236 }237 else{238 if(_end.bounds.b < _begin.bounds.t){239 if(_end.x > _begin.bounds.r){240 sPreset = "2";241 flipV = true;242 }243 else{244 sPreset = "4";245 flipH = true;246 flipV = true;247 oMapAdj["adj1"] = -((100000*(_begin.bounds.r + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);248 oMapAdj["adj2"] = (100000*(_begin.y - ((_end.bounds.b + _begin.bounds.t)/2.0))/extY + 0.5) >> 0;249 }250 }251 else{252 if(_end.x < _begin.x){253 if(_end.y > _begin.y){254 sPreset = "4";255 flipH = true;256 oMapAdj["adj1"] = -((100000*(Math.max(_begin.bounds.r, _end.bounds.r) + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);257 oMapAdj["adj2"] = (100000*((Math.max(_end.bounds.b, _begin.bounds.b) - _begin.y + CONNECTOR_MARGIN)/extY) + 0.5) >> 0;258 }259 else{260 sPreset = "4";261 flipH = true;262 flipV = true;263 oMapAdj["adj1"] = -((100000*(Math.max(_begin.bounds.r, _end.bounds.r) + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);264 oMapAdj["adj2"] = - (100000*((Math.max(_end.bounds.b, _begin.bounds.b) - _begin.y + CONNECTOR_MARGIN)/extY) + 0.5) >> 0;265 }266 }267 else{268 if(_end.y > _begin.y){269 sPreset = "4";270 oMapAdj["adj1"] = ((100000*(Math.max(_begin.bounds.r, _end.bounds.r) + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);271 oMapAdj["adj2"] = ((100000*(_end.bounds.b + CONNECTOR_MARGIN - _begin.y)/extY + 0.5) >> 0);272 }273 else{274 sPreset = "2";275 flipV = true;276 }277 }278 }279 }280 break;281 }282 case AscFormat.CARD_DIRECTION_W:{283 if(_begin.x < _end.x){284 sPreset = "3";285 flipV = _begin.y > _end.y;286 }287 else{288 sPreset = "5";289 if(_end.bounds.t > _begin.bounds.b){290 flipH = true;291 oMapAdj["adj1"] = -((100000*(_begin.bounds.r + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);292 oMapAdj["adj2"] = (100000*((_end.bounds.t + _begin.bounds.b)/2.0 - _begin.y)/extY + 0.5) >> 0;293 oMapAdj["adj3"] = (100000*(_begin.x - (_end.bounds.l - CONNECTOR_MARGIN))/extX + 0.5) >> 0;294 }295 else if(_end.bounds.b < _begin.bounds.t){296 flipH = true;297 flipV = true;298 oMapAdj["adj1"] = -((100000*(_begin.bounds.r + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);299 oMapAdj["adj2"] = (100000*(_begin.y - (_end.bounds.b + _begin.bounds.t)/2.0)/extY + 0.5) >> 0;300 oMapAdj["adj3"] = (100000*(_begin.x - (_end.bounds.l - CONNECTOR_MARGIN))/extX + 0.5) >> 0;301 }302 else{303 if(_end.y > _begin.y){304 flipH = true;305 oMapAdj["adj1"] = -((100000*(_begin.bounds.r + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);306 oMapAdj["adj2"] = (100000*(Math.max(_begin.bounds.b, _end.bounds.b) + CONNECTOR_MARGIN - _begin.y)/extY + 0.5) >> 0;307 oMapAdj["adj3"] = (100000*(_begin.x - (_end.bounds.l - CONNECTOR_MARGIN))/extX + 0.5) >> 0;308 }309 else{310 flipH = true;311 flipV = true;312 oMapAdj["adj1"] = -((100000*(_begin.bounds.r + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);313 oMapAdj["adj2"] = (100000*(_begin.y - (Math.min(_begin.bounds.t, _end.bounds.t) - CONNECTOR_MARGIN))/extY + 0.5) >> 0;314 oMapAdj["adj3"] = (100000*(_begin.x - (_end.bounds.l - CONNECTOR_MARGIN))/extX + 0.5) >> 0;315 }316 }317 }318 break;319 }320 case AscFormat.CARD_DIRECTION_E:{321 if(_end.bounds.l > _begin.bounds.r){322 if(_end.bounds.b < _begin.y ){323 sPreset = "3";324 flipV = true;325 oMapAdj["adj1"] = (100000*(_end.bounds.r + CONNECTOR_MARGIN - _begin.x)/extX) >> 0;326 }327 else if(_end.bounds.t > _begin.y){328 sPreset = "3";329 oMapAdj["adj1"] = 100000 + (100000*(CONNECTOR_MARGIN/extX) + 0.5) >> 0;330 }331 else{332 if(_end.y < _begin.y){333 sPreset = "5";334 flipV = true;335 oMapAdj["adj1"] = (100000*((_end.bounds.l + _begin.bounds.r)/2 - _begin.x)/extX + 0.5) >> 0;336 oMapAdj["adj2"] = (100000 + 100000*(_end.y - (_end.bounds.t - CONNECTOR_MARGIN))/extY + 0.5) >> 0;337 oMapAdj["adj3"] = 100000 + (100000*(_end.bounds.r + CONNECTOR_MARGIN - _end.x)/extX + 0.5) >> 0;338 }339 else{340 sPreset = "5";341 oMapAdj["adj1"] = (100000*((_end.bounds.l + _begin.bounds.r)/2 - _begin.x)/extX + 0.5) >> 0;342 oMapAdj["adj2"] = -(100000*(_begin.y - (_end.bounds.t - CONNECTOR_MARGIN))/extY + 0.5) >> 0;343 oMapAdj["adj3"] = 100000 + (100000*(_end.bounds.r + CONNECTOR_MARGIN - _end.x)/extX + 0.5) >> 0;344 }345 }346 }347 else{348 if(_end.x >= _begin.bounds.l || _end.y > _begin.bounds.b || _end.y < _begin.bounds.t){349 if(_end.y < _begin.y){350 if(_end.x < _begin.x){351 flipH = true;352 flipV = true;353 sPreset = "3";354 oMapAdj["adj1"] = -(100000*(Math.max(_end.bounds.r, _begin.bounds.r) + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0;355 }356 else {357 flipV = true;358 sPreset = "3";359 oMapAdj["adj1"] = 100000 + (100000*(Math.max(_end.bounds.r, _begin.bounds.r) + CONNECTOR_MARGIN - _end.x)/extX + 0.5) >> 0;360 }361 }362 else{363 if(_end.x < _begin.x){364 flipH = true;365 sPreset = "3";366 oMapAdj["adj1"] = -(100000*(Math.max(_end.bounds.r, _begin.bounds.r) + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0;367 }368 else {369 sPreset = "3";370 oMapAdj["adj1"] = 100000 + (100000*(Math.max(_end.bounds.r, _begin.bounds.r) + CONNECTOR_MARGIN - _end.x)/extX + 0.5) >> 0;371 }372 }373 }374 else{375 if(_end.y >= _begin.y){376 sPreset = "5";377 flipH = true;378 oMapAdj["adj1"] = -((100000*(CONNECTOR_MARGIN/extX) + 0.5) >> 0);379 oMapAdj["adj2"] = (100000 + 100000*(_begin.bounds.b + CONNECTOR_MARGIN - _end.y)/extY + 0.5) >> 0;380 oMapAdj["adj3"] = (100000*(_begin.x - (_end.bounds.r + _begin.bounds.l)/2.0)/extX + 0.5) >> 0;381 }382 else{383 sPreset = "5";384 flipH = true;385 flipV = true;386 oMapAdj["adj1"] = -((100000*(CONNECTOR_MARGIN/extX) + 0.5) >> 0);387 oMapAdj["adj2"] = -(100000*(_begin.bounds.b + CONNECTOR_MARGIN - _begin.y)/extY + 0.5) >> 0;388 oMapAdj["adj3"] = (100000*(_begin.x - (_end.bounds.r + _begin.bounds.l)/2.0)/extX + 0.5) >> 0;389 }390 }391 }392 break;393 }394 }395 sPreset = sPrefix + sPreset;396 }397 var _posX = (end.x + begin.x)/2.0 - extX/2.0;398 var _posY = (end.y + begin.y)/2.0 - extY/2.0;399 var _fAng = AscFormat.normalizeRotate(rot - fAngle);400 var oGeometry = AscFormat.CreateGeometry(sPreset);401 for(var key in oMapAdj){402 if(oMapAdj.hasOwnProperty(key)){403 oGeometry.setAdjValue(key, oMapAdj[key]);404 }405 }406 oSpPr.setGeometry(oGeometry);407 oGeometry.setParent(oSpPr);408 oXfrm.setOffX(_posX);409 oXfrm.setOffY(_posY);410 oXfrm.setExtX(extX);411 oXfrm.setExtY(extY);412 oXfrm.setRot(_fAng);413 oXfrm.setFlipH(flipH);414 oXfrm.setFlipV(flipV);415 return oSpPr;416 }, this, []);417 }418 function fCalculateConnectionInfo(oConnInfo, x, y) {419 var oConnecInfo2 = new ConnectionParams();420 oConnecInfo2.x = x;421 oConnecInfo2.y = y;422 oConnecInfo2.bounds.fromOther(new AscFormat.CGraphicBounds(x, y, x, y));423 var diffX = x - oConnInfo.x;424 var diffY = y - oConnInfo.y;425 if(Math.abs(diffX) > Math.abs(diffY)){426 if(diffX < 0){427 oConnecInfo2.dir = AscFormat.CARD_DIRECTION_E;428 }429 else{430 oConnecInfo2.dir = AscFormat.CARD_DIRECTION_W;431 }432 }433 else{434 if(diffY < 0){435 oConnecInfo2.dir = AscFormat.CARD_DIRECTION_S;436 }437 else{438 oConnecInfo2.dir = AscFormat.CARD_DIRECTION_N;439 }440 }441 return oConnecInfo2;442 }443 function CConnectionShape() {444 AscFormat.CShape.call(this);445 }446 CConnectionShape.prototype = Object.create(AscFormat.CShape.prototype);447 CConnectionShape.prototype.constructor = CConnectionShape;448 CConnectionShape.prototype.getObjectType = function(){449 return AscDFH.historyitem_type_Cnx;450 };451 CConnectionShape.prototype.copy = function () {452 var copy = new CConnectionShape();453 this.fillObject(copy);454 return copy;455 };456 CConnectionShape.prototype.resetShape = function (oShape) {457 var cnxPr = this.nvSpPr.nvUniSpPr;458 if(cnxPr.stCnxId === oShape.Id || cnxPr.endCnxId === oShape.Id){459 var oNewPr = cnxPr.copy();460 if(cnxPr.stCnxId === oShape.Id){461 oNewPr.stCnxId = null;462 oNewPr.stCnxIdx = null;463 }464 if(cnxPr.endCnxId === oShape.Id){465 oNewPr.endCnxId = null;466 oNewPr.endCnxIdx = null;467 }468 this.nvSpPr.setUniSpPr(oNewPr);469 }470 };471 CConnectionShape.prototype.getStCxnId = function(){472 return this.nvSpPr.nvUniSpPr.stCnxId;473 };474 CConnectionShape.prototype.getEndCxnId = function(){475 return this.nvSpPr.nvUniSpPr.endCnxId;476 };477 CConnectionShape.prototype.getStCxnIdx = function(){478 return this.nvSpPr.nvUniSpPr.stCnxIdx;479 };480 CConnectionShape.prototype.getEndCxnIdx = function(){481 return this.nvSpPr.nvUniSpPr.endCnxIdx;482 };483 CConnectionShape.prototype.calculateTransform = function (bMove) {484 var oBeginDrawing = null;485 var oEndDrawing = null;486 var sStId = this.getStCxnId();487 var sEndId = this.getEndCxnId();488 var _group;489 if(null !== sStId){490 oBeginDrawing = AscCommon.g_oTableId.Get_ById(sStId);491 if(oBeginDrawing && oBeginDrawing.bDeleted){492 oBeginDrawing = null;493 }494 if(oBeginDrawing){495 _group = oBeginDrawing.getMainGroup();496 if(_group){497 _group.recalculate();498 }499 else{500 oBeginDrawing.recalculate();501 }502 }503 }504 if(null !== sEndId){505 oEndDrawing = AscCommon.g_oTableId.Get_ById(sEndId);506 if(oEndDrawing && oEndDrawing.bDeleted){507 oEndDrawing = null;508 }509 if(oEndDrawing){510 _group = oEndDrawing.getMainGroup();511 if(_group){512 _group.recalculate();513 }514 else{515 oEndDrawing.recalculate();516 }517 }518 }519 var _startConnectionParams, _endConnectionParams, _spPr, _xfrm2;520 var _xfrm = this.spPr.xfrm;521 if(oBeginDrawing && oEndDrawing){522 _startConnectionParams = oBeginDrawing.getConnectionParams(this.getStCxnIdx(), null);523 _endConnectionParams = oEndDrawing.getConnectionParams(this.getEndCxnIdx(), null);524 _spPr = AscFormat.fCalculateSpPr(_startConnectionParams, _endConnectionParams, this.spPr.geometry.preset, this.pen.w);525 _xfrm2 = _spPr.xfrm;526 _xfrm.setExtX(_xfrm2.extX);527 _xfrm.setExtY(_xfrm2.extY);528 if(!this.group){529 _xfrm.setOffX(_xfrm2.offX);530 _xfrm.setOffY(_xfrm2.offY);531 _xfrm.setFlipH(_xfrm2.flipH);532 _xfrm.setFlipV(_xfrm2.flipV);533 _xfrm.setRot(_xfrm2.rot);534 }535 else{536 var _xc = _xfrm2.offX + _xfrm2.extX / 2.0;537 var _yc = _xfrm2.offY + _xfrm2.extY / 2.0;538 var xc = this.group.invertTransform.TransformPointX(_xc, _yc);539 var yc = this.group.invertTransform.TransformPointY(_xc, _yc);540 _xfrm.setOffX(xc - _xfrm2.extX / 2.0);541 _xfrm.setOffY(yc - _xfrm2.extY / 2.0);542 _xfrm.setFlipH(this.group.getFullFlipH() ? !_xfrm2.flipH : _xfrm2.flipH);543 _xfrm.setFlipV(this.group.getFullFlipV() ? !_xfrm2.flipV : _xfrm2.flipV);544 _xfrm.setRot(AscFormat.normalizeRotate(_xfrm2.rot - this.group.getFullRotate()));545 }546 this.spPr.setGeometry(_spPr.geometry.createDuplicate());547 this.checkDrawingBaseCoords();548 this.recalculate();549 }550 else if(oBeginDrawing || oEndDrawing){551 if(bMove){552 var _x, _y;553 var _spX, _spY, diffX, diffY, bChecked = false;554 var _oCnxInfo;555 var _groupTransform;556 if(oBeginDrawing){557 _oCnxInfo = oBeginDrawing.getGeom().cnxLst[this.getStCxnIdx()];558 if(_oCnxInfo){559 _spX = oBeginDrawing.transform.TransformPointX(_oCnxInfo.x, _oCnxInfo.y);560 _spY = oBeginDrawing.transform.TransformPointY(_oCnxInfo.x, _oCnxInfo.y);561 _x = this.transform.TransformPointX(0, 0);562 _y = this.transform.TransformPointY(0, 0);563 bChecked = true;564 }565 }566 else {567 _oCnxInfo = oEndDrawing.getGeom().cnxLst[this.getEndCxnIdx()];568 if(_oCnxInfo){569 _spX = oEndDrawing.transform.TransformPointX(_oCnxInfo.x, _oCnxInfo.y);570 _spY = oEndDrawing.transform.TransformPointY(_oCnxInfo.x, _oCnxInfo.y);571 _x = this.transform.TransformPointX(this.extX, this.extY);572 _y = this.transform.TransformPointY(this.extX, this.extY);573 bChecked = true;574 }575 }576 if(bChecked){577 if(this.group){578 _groupTransform = this.group.invertTransform.CreateDublicate();579 _groupTransform.tx = 0;580 _groupTransform.ty = 0;581 diffX = _groupTransform.TransformPointX(_spX - _x, _spY - _y);582 diffY = _groupTransform.TransformPointY(_spX - _x, _spY - _y);583 }584 else{585 diffX = _spX - _x;586 diffY = _spY - _y;587 }588 this.spPr.xfrm.setOffX(this.spPr.xfrm.offX + diffX);589 this.spPr.xfrm.setOffY(this.spPr.xfrm.offY + diffY);590 this.recalculate();591 }592 }593 else{594 if(oBeginDrawing){595 _startConnectionParams = oBeginDrawing.getConnectionParams(this.getStCxnIdx(), null);596 }597 if(oEndDrawing){598 _endConnectionParams = oEndDrawing.getConnectionParams(this.getEndCxnIdx(), null);599 }600 var _tx, _ty;601 if(_startConnectionParams || _endConnectionParams){602 if(!_startConnectionParams){603 _tx = this.transform.TransformPointX(0, 0);604 _ty = this.transform.TransformPointY(0, 0);605 _startConnectionParams = AscFormat.fCalculateConnectionInfo(_endConnectionParams, _tx, _ty);606 }607 if(!_endConnectionParams){608 _tx = this.transform.TransformPointX(this.extX, this.extY);609 _ty = this.transform.TransformPointY(this.extX, this.extY);610 _endConnectionParams = AscFormat.fCalculateConnectionInfo(_startConnectionParams, _tx, _ty);611 }612 _spPr = AscFormat.fCalculateSpPr(_startConnectionParams, _endConnectionParams, this.spPr.geometry.preset, this.pen && this.pen.w);613 _xfrm2 = _spPr.xfrm;614 _xfrm.setExtX(_xfrm2.extX);615 _xfrm.setExtY(_xfrm2.extY);616 if(!this.group){617 _xfrm.setOffX(_xfrm2.offX);618 _xfrm.setOffY(_xfrm2.offY);619 _xfrm.setFlipH(_xfrm2.flipH);620 _xfrm.setFlipV(_xfrm2.flipV);621 _xfrm.setRot(_xfrm2.rot);622 }623 else{624 var _xc = _xfrm2.offX + _xfrm2.extX / 2.0;625 var _yc = _xfrm2.offY + _xfrm2.extY / 2.0;626 var xc = this.group.invertTransform.TransformPointX(_xc, _yc);627 var yc = this.group.invertTransform.TransformPointY(_xc, _yc);628 _xfrm.setOffX(xc - _xfrm2.extX / 2.0);629 _xfrm.setOffY(yc - _xfrm2.extY / 2.0);630 _xfrm.setFlipH(this.group.getFullFlipH() ? !_xfrm2.flipH : _xfrm2.flipH);631 _xfrm.setFlipV(this.group.getFullFlipV() ? !_xfrm2.flipV : _xfrm2.flipV);632 _xfrm.setRot(AscFormat.normalizeRotate(_xfrm2.rot - this.group.getFullRotate()));633 }634 this.spPr.setGeometry(_spPr.geometry.createDuplicate());635 this.checkDrawingBaseCoords();636 this.recalculate();637 }638 }639 }640 };641 window['AscFormat'] = window['AscFormat'] || {};642 window['AscFormat'].fCalculateSpPr = fCalculateSpPr;643 window['AscFormat'].fCalculateConnectionInfo = fCalculateConnectionInfo;644 window['AscFormat'].ConnectionParams = ConnectionParams;645 window['AscFormat'].CConnectionShape = CConnectionShape;...

Full Screen

Full Screen

CnxShape.js

Source:CnxShape.js Github

copy

Full Screen

1/**2 * Created by Sergey.Luzyanin on 4/25/2017.3 */4(function(undefined){5 var CONNECTOR_MARGIN = 6.35;6 /**7 * @constructor8 * */9 function ConnectionParams(){10 this.bounds = new AscFormat.CGraphicBounds(0, 0, 0, 0);11 this.dir = AscFormat.CARD_DIRECTION_E;12 this.x = 0;13 this.y = 0;14 this.idx = 0;15 }16 ConnectionParams.prototype.copy = function(){17 var _c = new ConnectionParams();18 _c.bounds.fromOther(this.bounds);19 _c.dir = this.dir;20 _c.x = this.x;21 _c.y = this.y;22 _c.idx = this.idx;23 return _c;24 };25 ConnectionParams.prototype.transform = function(oTransform){26 this.bounds.transform(oTransform);27 //this.dir = AscFormat.CARD_DIRECTION_E;28 var _x = oTransform.TransformPointX(this.x, this.y);29 var _y = oTransform.TransformPointY(this.x, this.y);30 this.x = _x;31 this.y = _y;32 };33 function fCalculateSpPr(begin, end, sPreset, penW){34 return AscFormat.ExecuteNoHistory(function(){35 var oSpPr = new AscFormat.CSpPr();36 var oXfrm = new AscFormat.CXfrm();37 oSpPr.setXfrm(oXfrm);38 oXfrm.setParent(oSpPr);39 var _begin = begin.copy();40 var _end = end.copy();41 var fAngle = 0;42 if(!penW){43 penW = 12700;44 }45 switch(begin.dir){46 case AscFormat.CARD_DIRECTION_N:{47 fAngle = Math.PI/2;48 switch(_end.dir){49 case AscFormat.CARD_DIRECTION_N:{50 _end.dir = AscFormat.CARD_DIRECTION_E;51 break;52 }53 case AscFormat.CARD_DIRECTION_S:{54 _end.dir = AscFormat.CARD_DIRECTION_W;55 break;56 }57 case AscFormat.CARD_DIRECTION_W:{58 _end.dir = AscFormat.CARD_DIRECTION_N;59 break;60 }61 case AscFormat.CARD_DIRECTION_E:{62 _end.dir = AscFormat.CARD_DIRECTION_S;63 break;64 }65 }66 break;67 }68 case AscFormat.CARD_DIRECTION_S:{69 fAngle = -Math.PI/2;70 switch(_end.dir){71 case AscFormat.CARD_DIRECTION_N:{72 _end.dir = AscFormat.CARD_DIRECTION_W;73 break;74 }75 case AscFormat.CARD_DIRECTION_S:{76 _end.dir = AscFormat.CARD_DIRECTION_E;77 break;78 }79 case AscFormat.CARD_DIRECTION_W:{80 _end.dir = AscFormat.CARD_DIRECTION_S;81 break;82 }83 case AscFormat.CARD_DIRECTION_E:{84 _end.dir = AscFormat.CARD_DIRECTION_N;85 break;86 }87 }88 break;89 }90 case AscFormat.CARD_DIRECTION_W:{91 fAngle = Math.PI;92 switch(_end.dir){93 case AscFormat.CARD_DIRECTION_N:{94 _end.dir = AscFormat.CARD_DIRECTION_S;95 break;96 }97 case AscFormat.CARD_DIRECTION_S:{98 _end.dir = AscFormat.CARD_DIRECTION_N;99 break;100 }101 case AscFormat.CARD_DIRECTION_W:{102 _end.dir = AscFormat.CARD_DIRECTION_E;103 break;104 }105 case AscFormat.CARD_DIRECTION_E:{106 _end.dir = AscFormat.CARD_DIRECTION_W;107 break;108 }109 }110 break;111 }112 default:{113 //East is default direction114 fAngle = 0;115 break;116 }117 }118 var oTransform = new AscCommon.CMatrix();119 AscCommon.global_MatrixTransformer.RotateRadAppend(oTransform, -fAngle);120 _begin.transform(oTransform);121 _end.transform(oTransform);122 var extX = Math.max(penW/36000.0, Math.abs(_end.x - _begin.x));123 var extY = Math.max(penW/36000.0, Math.abs(_end.y - _begin.y));124 var flipV = false;125 var flipH = false;126 var rot = 0;127 var oMapAdj = {};128 if(sPreset === "line" ||129 sPreset.indexOf("straightConnector") > -1){130 flipH = (_begin.x > _end.x);131 flipV = (_begin.y > _end.y);132 }133 else{134 var sPrefix = "bentConnector";135 if(sPreset.indexOf("curvedConnector") > -1){136 sPrefix = "curvedConnector";137 }138 //returns "bentConnector" by default139 switch(_end.dir){140 case AscFormat.CARD_DIRECTION_N:{141 if(_end.bounds.l > _begin.bounds.r){142 if(_end.bounds.t < _begin.y){143 if(_end.y <= _begin.y){144 sPreset = "4";145 flipV = true;146 oMapAdj["adj1"] = (100000*(((_begin.bounds.r + _end.bounds.l)/2 - _begin.x)/extX) + 0.5) >> 0;147 oMapAdj["adj2"] = (100000*(_begin.y - (_end.bounds.t - CONNECTOR_MARGIN))/extY + 0.5) >> 0;148 }149 else{150 sPreset = "4";151 oMapAdj["adj1"] = (100000*(((_begin.bounds.r + _end.bounds.l)/2 - _begin.x)/extX) + 0.5) >> 0;152 oMapAdj["adj2"] = (-100000*( ( _begin.y - (_end.bounds.t - CONNECTOR_MARGIN) )/extY) + 0.5) >> 0;153 }154 }155 else{156 sPreset = "2";157 }158 }159 else{160 if(_end.bounds.t > _begin.bounds.b){161 if(_end.x < _begin.x){162 sPreset = "4";163 flipH = true;164 oMapAdj["adj1"] = -((100000*(_begin.bounds.r + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);165 oMapAdj["adj2"] = (100000*((_end.bounds.t + _begin.bounds.b)/2.0 - _begin.y)/extY) >> 0;166 }167 else{168 sPreset = "2";169 }170 }171 else if(_end.bounds.b < _begin.bounds.t){172 if(_end.x < _begin.x){173 sPreset = "4";174 flipH = true;175 flipV = true;176 oMapAdj["adj1"] = -((100000*(_begin.bounds.r + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);177 oMapAdj["adj2"] = (100000*(_begin.y - (_end.bounds.t - CONNECTOR_MARGIN))/extY + 0.5) >> 0;178 }179 else{180 sPreset = "4";181 flipV = true;182 oMapAdj["adj1"] = (100000*(Math.max(_begin.bounds.r, _end.bounds.r) + CONNECTOR_MARGIN - _begin.x)/extX) >> 0;183 oMapAdj["adj2"] = (100000*(_begin.y - (_end.bounds.t - CONNECTOR_MARGIN))/extY + 0.5) >> 0;184 }185 }186 else{187 if(_end.y < _begin.y){188 if(_end.x < _begin.x){189 sPreset = "4";190 flipH = true;191 flipV = true;192 oMapAdj["adj1"] = -((100000*(_begin.bounds.r + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);193 oMapAdj["adj2"] = (100000*(_begin.y - (_end.bounds.t - CONNECTOR_MARGIN))/extY + 0.5) >> 0;194 }195 else {196 sPreset = "4";197 flipV = true;198 oMapAdj["adj1"] = (100000*(Math.max(_begin.bounds.r, _end.bounds.r) + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0;199 oMapAdj["adj2"] = (100000*(_begin.y - (_end.bounds.t - CONNECTOR_MARGIN))/extY + 0.5) >> 0;200 }201 }202 else{203 if(_end.x > _begin.x){204 sPreset = "2";205 }206 else{207 sPreset = "4";208 flipH = true;209 oMapAdj["adj1"] = -(100000*(Math.max(_begin.bounds.r, _end.bounds.r) + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0;210 oMapAdj["adj2"] = -((100000*(_begin.y - (Math.min(_begin.bounds.t, _end.bounds.t) - CONNECTOR_MARGIN))/extY + 0.5) >> 0);211 }212 }213 }214 }215 break;216 }217 case AscFormat.CARD_DIRECTION_S:{218 if(_end.bounds.l > _begin.bounds.r){219 if(_end.bounds.b < _begin.y){220 sPreset = "2";221 flipV = true;222 }223 else{224 if(_end.y < _begin.y){225 sPreset = "4";226 flipV = true;227 oMapAdj["adj2"] = -((100000*((_end.bounds.b + CONNECTOR_MARGIN - _end.y)/extY) + 0.5) >> 0);228 oMapAdj["adj1"] = ((100000*(((_begin.bounds.r + _end.bounds.l)/2 - _begin.x))/extX) + 0.5) >> 0;229 }230 else{231 sPreset = "4";232 oMapAdj["adj1"] = (100000*(((_begin.bounds.r + _end.bounds.l)/2.0 - _begin.x)/extX) + 0.5) >> 0;233 oMapAdj["adj2"] = 100000 + ((100000*((_end.bounds.b + CONNECTOR_MARGIN - _end.y)/extY) + 0.5) >> 0);234 }235 }236 }237 else{238 if(_end.bounds.b < _begin.bounds.t){239 if(_end.x > _begin.bounds.r){240 sPreset = "2";241 flipV = true;242 }243 else{244 sPreset = "4";245 flipH = true;246 flipV = true;247 oMapAdj["adj1"] = -((100000*(_begin.bounds.r + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);248 oMapAdj["adj2"] = (100000*(_begin.y - ((_end.bounds.b + _begin.bounds.t)/2.0))/extY + 0.5) >> 0;249 }250 }251 else{252 if(_end.x < _begin.x){253 if(_end.y > _begin.y){254 sPreset = "4";255 flipH = true;256 oMapAdj["adj1"] = -((100000*(Math.max(_begin.bounds.r, _end.bounds.r) + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);257 oMapAdj["adj2"] = (100000*((Math.max(_end.bounds.b, _begin.bounds.b) - _begin.y + CONNECTOR_MARGIN)/extY) + 0.5) >> 0;258 }259 else{260 sPreset = "4";261 flipH = true;262 flipV = true;263 oMapAdj["adj1"] = -((100000*(Math.max(_begin.bounds.r, _end.bounds.r) + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);264 oMapAdj["adj2"] = - (100000*((Math.max(_end.bounds.b, _begin.bounds.b) - _begin.y + CONNECTOR_MARGIN)/extY) + 0.5) >> 0;265 }266 }267 else{268 if(_end.y > _begin.y){269 sPreset = "4";270 oMapAdj["adj1"] = ((100000*(Math.max(_begin.bounds.r, _end.bounds.r) + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);271 oMapAdj["adj2"] = ((100000*(_end.bounds.b + CONNECTOR_MARGIN - _begin.y)/extY + 0.5) >> 0);272 }273 else{274 sPreset = "2";275 flipV = true;276 }277 }278 }279 }280 break;281 }282 case AscFormat.CARD_DIRECTION_W:{283 if(_begin.x < _end.x){284 sPreset = "3";285 flipV = _begin.y > _end.y;286 }287 else{288 sPreset = "5";289 if(_end.bounds.t > _begin.bounds.b){290 flipH = true;291 oMapAdj["adj1"] = -((100000*(_begin.bounds.r + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);292 oMapAdj["adj2"] = (100000*((_end.bounds.t + _begin.bounds.b)/2.0 - _begin.y)/extY + 0.5) >> 0;293 oMapAdj["adj3"] = (100000*(_begin.x - (_end.bounds.l - CONNECTOR_MARGIN))/extX + 0.5) >> 0;294 }295 else if(_end.bounds.b < _begin.bounds.t){296 flipH = true;297 flipV = true;298 oMapAdj["adj1"] = -((100000*(_begin.bounds.r + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);299 oMapAdj["adj2"] = (100000*(_begin.y - (_end.bounds.b + _begin.bounds.t)/2.0)/extY + 0.5) >> 0;300 oMapAdj["adj3"] = (100000*(_begin.x - (_end.bounds.l - CONNECTOR_MARGIN))/extX + 0.5) >> 0;301 }302 else{303 if(_end.y > _begin.y){304 flipH = true;305 oMapAdj["adj1"] = -((100000*(_begin.bounds.r + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);306 oMapAdj["adj2"] = (100000*(Math.max(_begin.bounds.b, _end.bounds.b) + CONNECTOR_MARGIN - _begin.y)/extY + 0.5) >> 0;307 oMapAdj["adj3"] = (100000*(_begin.x - (_end.bounds.l - CONNECTOR_MARGIN))/extX + 0.5) >> 0;308 }309 else{310 flipH = true;311 flipV = true;312 oMapAdj["adj1"] = -((100000*(_begin.bounds.r + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0);313 oMapAdj["adj2"] = (100000*(_begin.y - (Math.min(_begin.bounds.t, _end.bounds.t) - CONNECTOR_MARGIN))/extY + 0.5) >> 0;314 oMapAdj["adj3"] = (100000*(_begin.x - (_end.bounds.l - CONNECTOR_MARGIN))/extX + 0.5) >> 0;315 }316 }317 }318 break;319 }320 case AscFormat.CARD_DIRECTION_E:{321 if(_end.bounds.l > _begin.bounds.r){322 if(_end.bounds.b < _begin.y ){323 sPreset = "3";324 flipV = true;325 oMapAdj["adj1"] = (100000*(_end.bounds.r + CONNECTOR_MARGIN - _begin.x)/extX) >> 0;326 }327 else if(_end.bounds.t > _begin.y){328 sPreset = "3";329 oMapAdj["adj1"] = 100000 + (100000*(CONNECTOR_MARGIN/extX) + 0.5) >> 0;330 }331 else{332 if(_end.y < _begin.y){333 sPreset = "5";334 flipV = true;335 oMapAdj["adj1"] = (100000*((_end.bounds.l + _begin.bounds.r)/2 - _begin.x)/extX + 0.5) >> 0;336 oMapAdj["adj2"] = (100000 + 100000*(_end.y - (_end.bounds.t - CONNECTOR_MARGIN))/extY + 0.5) >> 0;337 oMapAdj["adj3"] = 100000 + (100000*(_end.bounds.r + CONNECTOR_MARGIN - _end.x)/extX + 0.5) >> 0;338 }339 else{340 sPreset = "5";341 oMapAdj["adj1"] = (100000*((_end.bounds.l + _begin.bounds.r)/2 - _begin.x)/extX + 0.5) >> 0;342 oMapAdj["adj2"] = -(100000*(_begin.y - (_end.bounds.t - CONNECTOR_MARGIN))/extY + 0.5) >> 0;343 oMapAdj["adj3"] = 100000 + (100000*(_end.bounds.r + CONNECTOR_MARGIN - _end.x)/extX + 0.5) >> 0;344 }345 }346 }347 else{348 if(_end.x >= _begin.bounds.l || _end.y > _begin.bounds.b || _end.y < _begin.bounds.t){349 if(_end.y < _begin.y){350 if(_end.x < _begin.x){351 flipH = true;352 flipV = true;353 sPreset = "3";354 oMapAdj["adj1"] = -(100000*(Math.max(_end.bounds.r, _begin.bounds.r) + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0;355 }356 else {357 flipV = true;358 sPreset = "3";359 oMapAdj["adj1"] = 100000 + (100000*(Math.max(_end.bounds.r, _begin.bounds.r) + CONNECTOR_MARGIN - _end.x)/extX + 0.5) >> 0;360 }361 }362 else{363 if(_end.x < _begin.x){364 flipH = true;365 sPreset = "3";366 oMapAdj["adj1"] = -(100000*(Math.max(_end.bounds.r, _begin.bounds.r) + CONNECTOR_MARGIN - _begin.x)/extX + 0.5) >> 0;367 }368 else {369 sPreset = "3";370 oMapAdj["adj1"] = 100000 + (100000*(Math.max(_end.bounds.r, _begin.bounds.r) + CONNECTOR_MARGIN - _end.x)/extX + 0.5) >> 0;371 }372 }373 }374 else{375 if(_end.y >= _begin.y){376 sPreset = "5";377 flipH = true;378 oMapAdj["adj1"] = -((100000*(CONNECTOR_MARGIN/extX) + 0.5) >> 0);379 oMapAdj["adj2"] = (100000 + 100000*(_begin.bounds.b + CONNECTOR_MARGIN - _end.y)/extY + 0.5) >> 0;380 oMapAdj["adj3"] = (100000*(_begin.x - (_end.bounds.r + _begin.bounds.l)/2.0)/extX + 0.5) >> 0;381 }382 else{383 sPreset = "5";384 flipH = true;385 flipV = true;386 oMapAdj["adj1"] = -((100000*(CONNECTOR_MARGIN/extX) + 0.5) >> 0);387 oMapAdj["adj2"] = -(100000*(_begin.bounds.b + CONNECTOR_MARGIN - _begin.y)/extY + 0.5) >> 0;388 oMapAdj["adj3"] = (100000*(_begin.x - (_end.bounds.r + _begin.bounds.l)/2.0)/extX + 0.5) >> 0;389 }390 }391 }392 break;393 }394 }395 sPreset = sPrefix + sPreset;396 }397 var _posX = (end.x + begin.x)/2.0 - extX/2.0;398 var _posY = (end.y + begin.y)/2.0 - extY/2.0;399 var _fAng = AscFormat.normalizeRotate(rot - fAngle);400 var oGeometry = AscFormat.CreateGeometry(sPreset);401 for(var key in oMapAdj){402 if(oMapAdj.hasOwnProperty(key)){403 oGeometry.setAdjValue(key, oMapAdj[key]);404 }405 }406 oSpPr.setGeometry(oGeometry);407 oGeometry.setParent(oSpPr);408 oXfrm.setOffX(_posX);409 oXfrm.setOffY(_posY);410 oXfrm.setExtX(extX);411 oXfrm.setExtY(extY);412 oXfrm.setRot(_fAng);413 oXfrm.setFlipH(flipH);414 oXfrm.setFlipV(flipV);415 return oSpPr;416 }, this, []);417 }418 function fCalculateConnectionInfo(oConnInfo, x, y) {419 var oConnecInfo2 = new ConnectionParams();420 oConnecInfo2.x = x;421 oConnecInfo2.y = y;422 oConnecInfo2.bounds.fromOther(new AscFormat.CGraphicBounds(x, y, x, y));423 var diffX = x - oConnInfo.x;424 var diffY = y - oConnInfo.y;425 if(Math.abs(diffX) > Math.abs(diffY)){426 if(diffX < 0){427 oConnecInfo2.dir = AscFormat.CARD_DIRECTION_E;428 }429 else{430 oConnecInfo2.dir = AscFormat.CARD_DIRECTION_W;431 }432 }433 else{434 if(diffY < 0){435 oConnecInfo2.dir = AscFormat.CARD_DIRECTION_S;436 }437 else{438 oConnecInfo2.dir = AscFormat.CARD_DIRECTION_N;439 }440 }441 return oConnecInfo2;442 }443 function CConnectionShape() {444 AscFormat.CShape.call(this);445 }446 CConnectionShape.prototype = Object.create(AscFormat.CShape.prototype);447 CConnectionShape.prototype.constructor = CConnectionShape;448 CConnectionShape.prototype.getObjectType = function(){449 return AscDFH.historyitem_type_Cnx;450 };451 CConnectionShape.prototype.copy = function () {452 var copy = new CConnectionShape();453 this.fillObject(copy);454 return copy;455 };456 CConnectionShape.prototype.resetShape = function (oShape) {457 var cnxPr = this.nvSpPr.nvUniSpPr;458 if(cnxPr.stCnxId === oShape.Id || cnxPr.endCnxId === oShape.Id){459 var oNewPr = cnxPr.copy();460 if(cnxPr.stCnxId === oShape.Id){461 oNewPr.stCnxId = null;462 oNewPr.stCnxIdx = null;463 }464 if(cnxPr.endCnxId === oShape.Id){465 oNewPr.endCnxId = null;466 oNewPr.endCnxIdx = null;467 }468 this.nvSpPr.setUniSpPr(oNewPr);469 }470 };471 CConnectionShape.prototype.getStCxnId = function(){472 return this.nvSpPr.nvUniSpPr.stCnxId;473 };474 CConnectionShape.prototype.getEndCxnId = function(){475 return this.nvSpPr.nvUniSpPr.endCnxId;476 };477 CConnectionShape.prototype.getStCxnIdx = function(){478 return this.nvSpPr.nvUniSpPr.stCnxIdx;479 };480 CConnectionShape.prototype.getEndCxnIdx = function(){481 return this.nvSpPr.nvUniSpPr.endCnxIdx;482 };483 CConnectionShape.prototype.calculateTransform = function (bMove) {484 var oBeginDrawing = null;485 var oEndDrawing = null;486 var sStId = this.getStCxnId();487 var sEndId = this.getEndCxnId();488 var _group;489 if(null !== sStId){490 oBeginDrawing = AscCommon.g_oTableId.Get_ById(sStId);491 if(oBeginDrawing && oBeginDrawing.bDeleted){492 oBeginDrawing = null;493 }494 if(oBeginDrawing){495 _group = oBeginDrawing.getMainGroup();496 if(_group){497 _group.recalculate();498 }499 else{500 oBeginDrawing.recalculate();501 }502 }503 }504 if(null !== sEndId){505 oEndDrawing = AscCommon.g_oTableId.Get_ById(sEndId);506 if(oEndDrawing && oEndDrawing.bDeleted){507 oEndDrawing = null;508 }509 if(oEndDrawing){510 _group = oEndDrawing.getMainGroup();511 if(_group){512 _group.recalculate();513 }514 else{515 oEndDrawing.recalculate();516 }517 }518 }519 var _startConnectionParams, _endConnectionParams, _spPr, _xfrm2;520 var _xfrm = this.spPr.xfrm;521 if(oBeginDrawing && oEndDrawing){522 _startConnectionParams = oBeginDrawing.getConnectionParams(this.getStCxnIdx(), null);523 _endConnectionParams = oEndDrawing.getConnectionParams(this.getEndCxnIdx(), null);524 _spPr = AscFormat.fCalculateSpPr(_startConnectionParams, _endConnectionParams, this.spPr.geometry.preset, this.pen.w);525 _xfrm2 = _spPr.xfrm;526 _xfrm.setExtX(_xfrm2.extX);527 _xfrm.setExtY(_xfrm2.extY);528 if(!this.group){529 _xfrm.setOffX(_xfrm2.offX);530 _xfrm.setOffY(_xfrm2.offY);531 _xfrm.setFlipH(_xfrm2.flipH);532 _xfrm.setFlipV(_xfrm2.flipV);533 _xfrm.setRot(_xfrm2.rot);534 }535 else{536 var _xc = _xfrm2.offX + _xfrm2.extX / 2.0;537 var _yc = _xfrm2.offY + _xfrm2.extY / 2.0;538 var xc = this.group.invertTransform.TransformPointX(_xc, _yc);539 var yc = this.group.invertTransform.TransformPointY(_xc, _yc);540 _xfrm.setOffX(xc - _xfrm2.extX / 2.0);541 _xfrm.setOffY(yc - _xfrm2.extY / 2.0);542 _xfrm.setFlipH(this.group.getFullFlipH() ? !_xfrm2.flipH : _xfrm2.flipH);543 _xfrm.setFlipV(this.group.getFullFlipV() ? !_xfrm2.flipV : _xfrm2.flipV);544 _xfrm.setRot(AscFormat.normalizeRotate(_xfrm2.rot - this.group.getFullRotate()));545 }546 this.spPr.setGeometry(_spPr.geometry.createDuplicate());547 this.checkDrawingBaseCoords();548 this.recalculate();549 }550 else if(oBeginDrawing || oEndDrawing){551 if(bMove){552 var _x, _y;553 var _spX, _spY, diffX, diffY, bChecked = false;554 var _oCnxInfo;555 var _groupTransform;556 if(oBeginDrawing){557 _oCnxInfo = oBeginDrawing.getGeom().cnxLst[this.getStCxnIdx()];558 if(_oCnxInfo){559 _spX = oBeginDrawing.transform.TransformPointX(_oCnxInfo.x, _oCnxInfo.y);560 _spY = oBeginDrawing.transform.TransformPointY(_oCnxInfo.x, _oCnxInfo.y);561 _x = this.transform.TransformPointX(0, 0);562 _y = this.transform.TransformPointY(0, 0);563 bChecked = true;564 }565 }566 else {567 _oCnxInfo = oEndDrawing.getGeom().cnxLst[this.getEndCxnIdx()];568 if(_oCnxInfo){569 _spX = oEndDrawing.transform.TransformPointX(_oCnxInfo.x, _oCnxInfo.y);570 _spY = oEndDrawing.transform.TransformPointY(_oCnxInfo.x, _oCnxInfo.y);571 _x = this.transform.TransformPointX(this.extX, this.extY);572 _y = this.transform.TransformPointY(this.extX, this.extY);573 bChecked = true;574 }575 }576 if(bChecked){577 if(this.group){578 _groupTransform = this.group.invertTransform.CreateDublicate();579 _groupTransform.tx = 0;580 _groupTransform.ty = 0;581 diffX = _groupTransform.TransformPointX(_spX - _x, _spY - _y);582 diffY = _groupTransform.TransformPointY(_spX - _x, _spY - _y);583 }584 else{585 diffX = _spX - _x;586 diffY = _spY - _y;587 }588 this.spPr.xfrm.setOffX(this.spPr.xfrm.offX + diffX);589 this.spPr.xfrm.setOffY(this.spPr.xfrm.offY + diffY);590 this.recalculate();591 }592 }593 else{594 if(oBeginDrawing){595 _startConnectionParams = oBeginDrawing.getConnectionParams(this.getStCxnIdx(), null);596 }597 if(oEndDrawing){598 _endConnectionParams = oEndDrawing.getConnectionParams(this.getEndCxnIdx(), null);599 }600 var _tx, _ty;601 if(_startConnectionParams || _endConnectionParams){602 if(!_startConnectionParams){603 _tx = this.transform.TransformPointX(0, 0);604 _ty = this.transform.TransformPointY(0, 0);605 _startConnectionParams = AscFormat.fCalculateConnectionInfo(_endConnectionParams, _tx, _ty);606 }607 if(!_endConnectionParams){608 _tx = this.transform.TransformPointX(this.extX, this.extY);609 _ty = this.transform.TransformPointY(this.extX, this.extY);610 _endConnectionParams = AscFormat.fCalculateConnectionInfo(_startConnectionParams, _tx, _ty);611 }612 _spPr = AscFormat.fCalculateSpPr(_startConnectionParams, _endConnectionParams, this.spPr.geometry.preset, this.pen && this.pen.w);613 _xfrm2 = _spPr.xfrm;614 _xfrm.setExtX(_xfrm2.extX);615 _xfrm.setExtY(_xfrm2.extY);616 if(!this.group){617 _xfrm.setOffX(_xfrm2.offX);618 _xfrm.setOffY(_xfrm2.offY);619 _xfrm.setFlipH(_xfrm2.flipH);620 _xfrm.setFlipV(_xfrm2.flipV);621 _xfrm.setRot(_xfrm2.rot);622 }623 else{624 var _xc = _xfrm2.offX + _xfrm2.extX / 2.0;625 var _yc = _xfrm2.offY + _xfrm2.extY / 2.0;626 var xc = this.group.invertTransform.TransformPointX(_xc, _yc);627 var yc = this.group.invertTransform.TransformPointY(_xc, _yc);628 _xfrm.setOffX(xc - _xfrm2.extX / 2.0);629 _xfrm.setOffY(yc - _xfrm2.extY / 2.0);630 _xfrm.setFlipH(this.group.getFullFlipH() ? !_xfrm2.flipH : _xfrm2.flipH);631 _xfrm.setFlipV(this.group.getFullFlipV() ? !_xfrm2.flipV : _xfrm2.flipV);632 _xfrm.setRot(AscFormat.normalizeRotate(_xfrm2.rot - this.group.getFullRotate()));633 }634 this.spPr.setGeometry(_spPr.geometry.createDuplicate());635 this.checkDrawingBaseCoords();636 this.recalculate();637 }638 }639 }640 };641 window['AscFormat'] = window['AscFormat'] || {};642 window['AscFormat'].fCalculateSpPr = fCalculateSpPr;643 window['AscFormat'].fCalculateConnectionInfo = fCalculateConnectionInfo;644 window['AscFormat'].ConnectionParams = ConnectionParams;645 window['AscFormat'].CConnectionShape = CConnectionShape;...

Full Screen

Full Screen

WideInterval.js

Source:WideInterval.js Github

copy

Full Screen

1/*2 * This file is part of YoHours.3 * 4 * YoHours is free software: you can redistribute it and/or modify5 * it under the terms of the GNU Affero General Public License as published by6 * the Free Software Foundation, either version 3 of the License, or7 * any later version.8 * 9 * YoHours is distributed in the hope that it will be useful,10 * but WITHOUT ANY WARRANTY; without even the implied warranty of11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12 * GNU Affero General Public License for more details.13 * 14 * You should have received a copy of the GNU Affero General Public License15 * along with YoHours. If not, see <http://www.gnu.org/licenses/>.16 */17//IMPORTS18let Constants = require("./Constants");19/**20 * A wide interval is an interval of one or more days, weeks, months, holidays.21 * Use WideInterval.days/weeks/months/holidays methods to construct one object.22 */23class WideInterval {24//CONSTRUCTOR25 constructor() {26 /** The start of the interval **/27 this._start = null;28 29 /** The end of the interval **/30 this._end = null;31 /** The kind of interval **/32 this._type = null;33 }34//CONSTRUCTORS35 /**36 * @return a day-based interval37 */38 day(startDay, startMonth, endDay, endMonth) {39 if(startDay == null || startMonth == null) {40 throw Error("Start day and month can't be null");41 }42 this._start = { day: startDay, month: startMonth };43 this._end = (endDay != null && endMonth != null && (endDay != startDay || endMonth != startMonth)) ? { day: endDay, month: endMonth } : null;44 this._type = "day";45 return this;46 }47 48 /**49 * @return a week-based interval50 */51 week(startWeek, endWeek) {52 if(startWeek == null) {53 throw Error("Start week can't be null");54 }55 this._start = { week: startWeek };56 this._end = (endWeek != null && endWeek != startWeek) ? { week: endWeek } : null;57 this._type = "week";58 return this;59 }60 61 /**62 * @return a month-based interval63 */64 month(startMonth, endMonth) {65 if(startMonth == null) {66 throw Error("Start month can't be null");67 }68 this._start = { month: startMonth };69 this._end = (endMonth != null && endMonth != startMonth) ? { month: endMonth } : null;70 this._type = "month";71 return this;72 }73 74 /**75 * @return a holiday-based interval76 */77 holiday(holiday) {78 if(holiday == null || (holiday != "PH" && holiday != "SH" && holiday != "easter")) {79 throw Error("Invalid holiday, must be PH, SH or easter");80 }81 this._start = { holiday: holiday };82 this._end = null;83 this._type = "holiday";84 return this;85 }86 87 /**88 * @return a holiday-based interval89 */90 always() {91 this._start = null;92 this._end = null;93 this._type = "always";94 return this;95 }96//ACCESSORS97 /**98 * @return The kind of wide interval (always, day, month, week, holiday)99 */100 getType() {101 return this._type;102 }103 104 /**105 * @return The start moment106 */107 getStart() {108 return this._start;109 }110 111 /**112 * @return The end moment113 */114 getEnd() {115 return this._end;116 }117 118 /**119 * @return True if the given object concerns the same interval as this one120 */121 equals(o) {122 if(!o instanceof WideInterval) { return false; }123 if(this === o) { return true; }124 if(o._type == "always") { return this._type == "always"; }125 let result = false;126 127 switch(this._type) {128 case "always":129 result = o._start == null;130 break;131 case "day":132 result =133 (134 o._type == "day"135 && o._start.month == this._start.month136 && o._start.day == this._start.day137 && (138 (o._end == null && this._end == null)139 || (o._end != null && this._end != null && this._end.month == o._end.month && this._end.day == o._end.day)140 ))141 ||142 (143 o._type == "month"144 && o._start.month == this._start.month145 && (this.isFullMonth() && o.isFullMonth())146 || (o._end != null && this._end != null && this._end.month == o._end.month && this.endsMonth() && o.endsMonth())147 );148 break;149 case "week":150 result =151 o._start.week == this._start.week152 && (o._end == this._end || (this._end != null && o._end != null && o._end.week == this._end.week));153 break;154 case "month":155 result = 156 (157 o._type == "day"158 && this._start.month == o._start.month159 && o.startsMonth()160 && (161 (this._end == null && o._end != null && this._start.month == o._end.month && o.endsMonth())162 ||163 (this._end != null && o._end != null && this._end.month == o._end.month && o.endsMonth())164 )165 )166 ||167 (168 o._type == "month"169 && o._start.month == this._start.month170 && (171 (this._end == null && o._end == null)172 ||173 (this._end != null && o._end != null && this._end.month == o._end.month)174 )175 );176 break;177 case "holiday":178 result = o._start.holiday == this._start.holiday;179 break;180 default:181 }182 183 return result;184 }185 186 /**187 * @return The human readable time188 */189 getTimeForHumans() {190 let result;191 192 switch(this._type) {193 case "day":194 if(this._end != null) {195 result = "every week from "+Constants.IRL_MONTHS[this._start.month-1]+" "+this._start.day+" to ";196 if(this._start.month != this._end.month) { result += Constants.IRL_MONTHS[this._end.month-1]+" "; }197 result += this._end.day;198 }199 else {200 result = "day "+Constants.IRL_MONTHS[this._start.month-1]+" "+this._start.day;201 }202 break;203 case "week":204 if(this._end != null) {205 result = "every week from week "+this._start.week+" to "+this._end.week;206 }207 else {208 result = "week "+this._start.week;209 }210 break;211 case "month":212 if(this._end != null) {213 result = "every week from "+Constants.IRL_MONTHS[this._start.month-1]+" to "+Constants.IRL_MONTHS[this._end.month-1];214 }215 else {216 result = "every week in "+Constants.IRL_MONTHS[this._start.month-1];217 }218 break;219 case "holiday":220 if(this._start.holiday == "SH") {221 result = "every week during school holidays";222 }223 else if(this._start.holiday == "PH") {224 result = "every public holidays";225 }226 else if(this._start.holiday == "easter") {227 result = "each easter day";228 }229 else {230 throw new Error("Invalid holiday type: "+this._start.holiday);231 }232 break;233 case "always":234 result = "every week of year";235 break;236 default:237 result = "invalid time";238 }239 240 return result;241 }242 243 /**244 * @return The time selector for OSM opening_hours245 */246 getTimeSelector() {247 let result;248 249 switch(this._type) {250 case "day":251 result = Constants.OSM_MONTHS[this._start.month-1]+" "+((this._start.day < 10) ? "0" : "")+this._start.day;252 if(this._end != null) {253 //Same month as start ?254 if(this._start.month == this._end.month) {255 result += "-"+((this._end.day < 10) ? "0" : "")+this._end.day;256 }257 else {258 result += "-"+Constants.OSM_MONTHS[this._end.month-1]+" "+((this._end.day < 10) ? "0" : "")+this._end.day;259 }260 }261 break;262 case "week":263 result = "week "+((this._start.week < 10) ? "0" : "")+this._start.week;264 if(this._end != null) {265 result += "-"+((this._end.week < 10) ? "0" : "")+this._end.week;266 }267 break;268 case "month":269 result = Constants.OSM_MONTHS[this._start.month-1];270 if(this._end != null) {271 result += "-"+Constants.OSM_MONTHS[this._end.month-1];272 }273 break;274 case "holiday":275 result = this._start.holiday;276 break;277 case "always":278 default:279 result = "";280 }281 282 return result;283 }284 285 /**286 * Does this interval corresponds to a full month ?287 */288 isFullMonth() {289 if(this._type == "month" && this._end == null) {290 return true;291 }292 else if(this._type == "day") {293 return (this._start.day == 1 && this._end != null && this._end.month == this._start.month && this._end.day != undefined && this._end.day == Constants.MONTH_END_DAY[this._end.month-1]);294 }295 else {296 return false;297 }298 }299 300 /**301 * Does this interval starts the first day of a month302 */303 startsMonth() {304 return this._type == "month" || this._type == "always" || (this._type == "day" && this._start.day == 1);305 }306 307 /**308 * Does this interval ends the last day of a month309 */310 endsMonth() {311 return this._type == "month" || this._type == "always" || (this._type == "day" && this._end != null && this._end.day == Constants.MONTH_END_DAY[this._end.month-1]);312 }313 314 /**315 * Does this interval strictly contains the given one (ie the second is a refinement of the first, and not strictly equal)316 * @param o The other wide interval317 * @return True if this date contains the given one (and is not strictly equal to)318 */319 contains(o) {320 let result = false;321 322 /*323 * Check if it is contained in this one324 */325 if(this.equals(o)) {326 result = false;327 }328 else if(this._type == "always") {329 result = true;330 }331 else if(this._type == "day") {332 if(o._type == "day") {333 //Starting after334 if(o._start.month > this._start.month || (o._start.month == this._start.month && o._start.day >= this._start.day)) {335 //Ending before336 if(o._end != null) {337 if(this._end != null && (o._end.month < this._end.month || (o._end.month == this._end.month && o._end.day <= this._end.day))) {338 result = true;339 }340 }341 else {342 if(this._end != null && (o._start.month < this._end.month || (o._start.month == this._end.month && o._start.day <= this._end.day))) {343 result = true;344 }345 }346 }347 }348 else if(o._type == "month"){349 //Starting after350 if(o._start.month > this._start.month || (o._start.month == this._start.month && this._start.day == 1)) {351 //Ending before352 if(o._end != null && this._end != null && (o._end.month < this._end.month || (o._end.month == this._end.month && this._end.day == Constants.MONTH_END_DAY[end.month-1]))) {353 result = true;354 }355 else if(o._end == null && (this._end != null && o._start.month < this._end.month)) {356 result = true;357 }358 }359 }360 }361 else if(this._type == "week") {362 if(o._type == "week") {363 if(o._start.week >= this._start.week) {364 if(o._end != null && this._end != null && o._end.week <= this._end.week) {365 result = true;366 }367 else if(o._end == null && ((this._end != null && o._start.week <= this._end.week) || o._start.week == this._start.week)) {368 result = true;369 }370 }371 }372 }373 else if(this._type == "month") {374 if(o._type == "month") {375 if(o._start.month >= this._start.month) {376 if(o._end != null && this._end != null && o._end.month <= this._end.month) {377 result = true;378 }379 else if(o._end == null && ((this._end != null && o._start.month <= this._end.month) || o._start.month == this._start.month)) {380 result = true;381 }382 }383 }384 else if(o._type == "day") {385 if(o._end != null) {386 if(this._end == null) {387 if(388 o._start.month == this._start.month389 && o._end.month == this._start.month390 && ((o._start.day >= 1 && o._end.day < Constants.MONTH_END_DAY[o._start.month-1])391 || (o._start.day > 1 && o._end.day <= Constants.MONTH_END_DAY[o._start.month-1]))392 ) {393 result = true;394 }395 }396 else {397 if(o._start.month >= this._start.month && o._end.month <= this._end.month) {398 if(399 (o._start.month > this._start.month && o._end.month < this._end.month)400 || (o._start.month == this._start.month && o._end.month < this._end.month && o._start.day > 1)401 || (o._start.month > this._start.month && o._end.month == this._end.month && o._end.day < Constants.MONTH_END_DAY[o._end.month-1])402 || (o._start.day >= 1 && o._end.day < Constants.MONTH_END_DAY[o._end.month-1])403 || (o._start.day > 1 && o._end.day <= Constants.MONTH_END_DAY[o._end.month-1])404 ) {405 result = true;406 }407 }408 }409 }410 else {411 if(this._end == null) {412 if(this._start.month == o._start.month) {413 result = true;414 }415 }416 else {417 if(o._start.month >= this._start.month && o._start.month <= this._end.month) {418 result = true;419 }420 }421 }422 }423 }424 425 return result;426 }427}...

Full Screen

Full Screen

animation.js

Source:animation.js Github

copy

Full Screen

1import { WebMercator } from "../projection/web-mercator";2/**3 * 动画效果基类4 * @remarks5 * 动画两种实现方式:6 * 1.针对单个图形要素,实现动画,使用时,逻辑较清晰;7 * 2.针对整个图层,类似Symbol,使用时,可能存在效率问题;8 * 目前暂实现1,针对2,目前保留部分已注释的代码,便于日后参考。9 */10export class Animation {11 /**12 * 动画效果初始化13 * @remarks14 * 一般情况下,把一次性逻辑放于此处,以及处理动画的初始状态15 * @param {CanvasRenderingContext2D} ctx - 绘图上下文16 * @param {Projection} projection - 坐标投影转换17 */18 init(ctx, projection = new WebMercator()) {19 }20 /**21 * 动画效果22 * @remarks23 * 通过Animator中requestAnimationFrame循环调用,因此注意优化代码,保持帧数24 * @param {number} elapsed - 已逝去的时间,毫秒25 * @param {CanvasRenderingContext2D} ctx - 绘图上下文26 */27 animate(elapsed, ctx) {28 }29}30/**31 * 点默认动画效果类32 * @remarks33 * 类似flashing效果,从中心点向外光环扩散效果34 */35export class PointAnimation extends Animation {36 //radius: number = this.limit / this.ring;37 /**38 * 创建动画效果39 * @param {Point} geometry - 点40 */41 constructor(geometry) {42 super();43 /**44 * 边宽45 */46 this.lineWidth = 2;47 /**48 * 颜色49 */50 this.color = "#ff0000";51 /**52 * 扩散速度53 */54 this.velocity = 10; // px/s55 /**56 * 扩散的最大半径57 */58 this.limit = 30;59 /**60 * 扩散的光圈数61 */62 this.ring = 3;63 this._point = geometry;64 }65 /**66 * 动画效果初始化67 * @remarks68 * 一般情况下,把一次性逻辑放于此处,以及处理动画的初始状态69 * @param {CanvasRenderingContext2D} ctx - 绘图上下文70 * @param {Projection} projection - 坐标投影转换71 */72 init(ctx, projection = new WebMercator()) {73 this._point.project(projection);74 const matrix = ctx.getTransform();75 this._screenX = (matrix.a * this._point.x + matrix.e);76 this._screenY = (matrix.d * this._point.y + matrix.f);77 /*ctx.save();78 ctx.strokeStyle = this.color;79 ctx.lineWidth = this.lineWidth;80 //keep size81 //地理坐标 转回 屏幕坐标82 ctx.setTransform(1,0,0,1,0,0);83 ctx.beginPath(); //Start path84 ctx.arc(this._screenX, this._screenY, this.limit / this.ring, 0, Math.PI * 2, true);85 ctx.stroke();86 ctx.restore();*/87 }88 /**89 * 动画效果90 * @remarks91 * 通过Animator中requestAnimationFrame循环调用,因此注意优化代码,保持帧数92 * @param {number} elapsed - 已逝去的时间,毫秒93 * @param {CanvasRenderingContext2D} ctx - 绘图上下文94 */95 animate(elapsed, ctx) {96 ctx.save();97 ctx.strokeStyle = this.color;98 ctx.lineWidth = this.lineWidth;99 //keep size100 //地理坐标 转回 屏幕坐标101 ctx.setTransform(1, 0, 0, 1, 0, 0);102 /*ctx.arc(this._screenX, this._screenY, this.limit / this.ring, 0, Math.PI * 2, true);103 ctx.fill();*/104 for (let i = 0; i < this.ring; i++) {105 ctx.beginPath(); //Start path106 ctx.arc(this._screenX, this._screenY, (elapsed / 1000 * this.velocity + i * this.limit / this.ring) % this.limit, 0, Math.PI * 2, true);107 //ctx.arc(this._screenX, this._screenY, this.limit / this.ring + ((elapsed/1000 + (this.limit - this.limit / this.ring) / this.velocity * (i/(this.ring - 1))) * this.velocity) % this.limit, 0, Math.PI * 2, true);108 ctx.stroke();109 }110 ctx.restore();111 }112}113/**114 * 线默认动画效果类115 * @remarks116 * 类似航线效果117 */118export class LineAnimation extends Animation {119 /**120 * 创建动画效果121 * @param {Polyline} geometry - 线122 */123 constructor(geometry) {124 super();125 this._percent = 0;126 /**127 * 线宽128 */129 this.lineWidth = 2;130 /**131 * 起始色132 */133 this.startColor = "#ff0000";134 /**135 * 终止色136 */137 this.endColor = "#ffff00";138 /**139 * 二次贝塞尔曲线控制点与线段夹角140 */141 this.angle = Math.PI / 4;142 this._polyline = geometry;143 }144 /**145 * 动画效果初始化146 * @remarks147 * 一般情况下,把一次性逻辑放于此处,以及处理动画的初始状态148 * @param {CanvasRenderingContext2D} ctx - 绘图上下文149 * @param {Projection} projection - 坐标投影转换150 */151 init(ctx, projection = new WebMercator()) {152 this._polyline.project(projection);153 const matrix = ctx.getTransform();154 this._screen = this._polyline.coordinates.map((point, index) => {155 const screenX = (matrix.a * point[0] + matrix.e), screenY = (matrix.d * point[1] + matrix.f);156 return [screenX, screenY];157 });158 //TODO: polyline, not line; but now just line159 this._start = this._screen[0];160 this._end = this._screen[1];161 const k = (this._end[1] - this._start[1]) / (this._end[0] - this._start[0]);162 const d = Math.sqrt((this._end[1] - this._start[1]) * (this._end[1] - this._start[1]) + (this._end[0] - this._start[0]) * (this._end[0] - this._start[0]));163 const s = d / 2 / Math.cos(this.angle);164 //const a = (Math.atan(k) < 0 ? (Math.PI + Math.atan(k)) : Math.atan(k)) - this.angle;165 //this._control = this._start[0] >= this._end[0] ? [this._start[0] + s * Math.cos(a), this._start[1] + s * Math.sin(a)] : [this._end[0] + s * Math.cos(a), this._end[1] + s * Math.sin(a)];166 const a = Math.atan(k) - this.angle;167 if (Math.atan(k) < 0) {168 if (this._end[0] > this._start[0]) {169 this._control = [this._start[0] + s * Math.cos(a), this._start[1] + s * Math.sin(a)];170 }171 else {172 this._control = [this._end[0] + s * Math.cos(a), this._end[1] + s * Math.sin(a)];173 }174 }175 else {176 if (this._end[0] > this._start[0]) {177 this._control = [this._start[0] + s * Math.cos(a), this._start[1] + s * Math.sin(a)];178 }179 else {180 this._control = [this._end[0] + s * Math.cos(a), this._end[1] + s * Math.sin(a)];181 }182 }183 this._percent = 0;184 }185 /**186 * 动画效果187 * @remarks188 * 通过Animator中requestAnimationFrame循环调用,因此注意优化代码,保持帧数189 * @param {number} elapsed - 已逝去的时间,毫秒190 * @param {CanvasRenderingContext2D} ctx - 绘图上下文191 */192 animate(elapsed, ctx) {193 ctx.save();194 ctx.lineWidth = this.lineWidth;195 //keep size196 //地理坐标 转回 屏幕坐标197 ctx.setTransform(1, 0, 0, 1, 0, 0);198 const lineGradient = ctx.createLinearGradient(this._start[0], this._start[1], this._end[0], this._end[1]);199 lineGradient.addColorStop(0, this.startColor);200 // lineGradient.addColorStop(0.3, '#fff');201 lineGradient.addColorStop(1, this.endColor);202 ctx.strokeStyle = lineGradient; //设置线条样式203 this._drawCurvePath(ctx, this._start, this._control, this._end, this._percent);204 this._percent += 0.8; //进程增加,这个控制动画速度205 if (this._percent >= 100) { //没有画完接着调用,画完的话重置进度206 this._percent = 0;207 }208 }209 _drawCurvePath(ctx, start, point, end, percent) {210 ctx.beginPath();211 ctx.moveTo(start[0], start[1]);212 for (let t = 0; t <= percent / 100; t += 0.005) {213 let x = this._quadraticBezier(start[0], point[0], end[0], t);214 let y = this._quadraticBezier(start[1], point[1], end[1], t);215 ctx.lineTo(x, y);216 }217 ctx.stroke();218 }219 _quadraticBezier(p0, p1, p2, t) {220 let k = 1 - t;221 return k * k * p0 + 2 * (1 - t) * t * p1 + t * t * p2; // 二次贝赛尔曲线方程222 }...

Full Screen

Full Screen

capture-hard-navigation.spec.js

Source:capture-hard-navigation.spec.js Github

copy

Full Screen

1/**2 * MIT License3 *4 * Copyright (c) 2017-present, Elasticsearch BV5 *6 * Permission is hereby granted, free of charge, to any person obtaining a copy7 * of this software and associated documentation files (the "Software"), to deal8 * in the Software without restriction, including without limitation the rights9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell10 * copies of the Software, and to permit persons to whom the Software is11 * furnished to do so, subject to the following conditions:12 *13 * The above copyright notice and this permission notice shall be included in14 * all copies or substantial portions of the Software.15 *16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN22 * THE SOFTWARE.23 *24 */25var navigationTiming = require('../../src/performance-monitoring/capture-hard-navigation')26var Transaction = require('../../src/performance-monitoring/transaction')27var resourceEntries = require('../fixtures/resource-entries')28var spanSnapshot = require('./navigation-timing-span-snapshot').map(mapSpan)29function mapSpan (s) {30 return { name: s.name, _end: s._end, _start: s._start }31}32describe('navigationTiming', function () {33 it('should createNavigationTimingSpans', function () {34 var timings = {35 navigationStart: 1528373292350,36 unloadEventStart: 1528373293147,37 unloadEventEnd: 1528373293147,38 redirectStart: 0,39 redirectEnd: 0,40 fetchStart: 1528373292356,41 domainLookupStart: 1528373292356,42 domainLookupEnd: 1528373292356,43 connectStart: 1528373292356,44 connectEnd: 1528373292356,45 secureConnectionStart: 0,46 requestStart: 1528373292363,47 responseStart: 1528373293142,48 responseEnd: 1528373293303,49 domLoading: 1528373293176,50 domInteractive: 1528373293820,51 domContentLoadedEventStart: 1528373293820,52 domContentLoadedEventEnd: 1528373293854,53 domComplete: 1528373295207,54 loadEventStart: 1528373295208,55 loadEventEnd: 152837329523056 }57 var spans = navigationTiming.createNavigationTimingSpans(timings, timings.fetchStart)58 expect(spans.map(mapSpan)).toEqual([59 { name: 'Requesting and receiving the document', _end: 947, _start: 7 },60 { name: 'Parsing the document, executing sync. scripts', _end: 1464, _start: 820 },61 { name: 'Fire "DOMContentLoaded" event', _end: 1498, _start: 1464 },62 { name: 'Fire "load" event', _end: 2874, _start: 2852 }63 ])64 spans = navigationTiming.createNavigationTimingSpans(timings, null)65 expect(spans).toEqual([])66 spans = navigationTiming.createNavigationTimingSpans(timings, undefined)67 expect(spans).toEqual([])68 spans = navigationTiming.createNavigationTimingSpans(timings, 0)69 expect(spans).toEqual([])70 spans = navigationTiming.createNavigationTimingSpans(timings, 1)71 expect(spans).toEqual([])72 spans = navigationTiming.createNavigationTimingSpans(timings, Number(new Date()))73 expect(spans).toEqual([])74 timings.requestStart = null75 spans = navigationTiming.createNavigationTimingSpans(timings, timings.fetchStart)76 expect(spans.map(mapSpan)).toEqual([77 { name: 'Parsing the document, executing sync. scripts', _end: 1464, _start: 820 },78 { name: 'Fire "DOMContentLoaded" event', _end: 1498, _start: 1464 },79 { name: 'Fire "load" event', _end: 2874, _start: 2852 }80 ])81 timings.requestStart = undefined82 spans = navigationTiming.createNavigationTimingSpans(timings, timings.fetchStart)83 expect(spans.map(mapSpan)).toEqual([84 { name: 'Parsing the document, executing sync. scripts', _end: 1464, _start: 820 },85 { name: 'Fire "DOMContentLoaded" event', _end: 1498, _start: 1464 },86 { name: 'Fire "load" event', _end: 2874, _start: 2852 }87 ])88 timings.requestStart = 089 spans = navigationTiming.createNavigationTimingSpans(timings, timings.fetchStart)90 expect(spans.map(mapSpan)).toEqual([91 { name: 'Parsing the document, executing sync. scripts', _end: 1464, _start: 820 },92 { name: 'Fire "DOMContentLoaded" event', _end: 1498, _start: 1464 },93 { name: 'Fire "load" event', _end: 2874, _start: 2852 }94 ])95 timings.requestStart = 196 spans = navigationTiming.createNavigationTimingSpans(timings, timings.fetchStart)97 expect(spans.map(mapSpan)).toEqual([98 { name: 'Parsing the document, executing sync. scripts', _end: 1464, _start: 820 },99 { name: 'Fire "DOMContentLoaded" event', _end: 1498, _start: 1464 },100 { name: 'Fire "load" event', _end: 2874, _start: 2852 }101 ])102 timings.requestStart = Number(new Date())103 spans = navigationTiming.createNavigationTimingSpans(timings, timings.fetchStart)104 expect(spans.map(mapSpan)).toEqual([105 { name: 'Parsing the document, executing sync. scripts', _end: 1464, _start: 820 },106 { name: 'Fire "DOMContentLoaded" event', _end: 1498, _start: 1464 },107 { name: 'Fire "load" event', _end: 2874, _start: 2852 }108 ])109 // testing the end110 timings.domInteractive = null111 spans = navigationTiming.createNavigationTimingSpans(timings, timings.fetchStart)112 expect(spans.map(mapSpan)).toEqual([113 { name: 'Fire "DOMContentLoaded" event', _end: 1498, _start: 1464 },114 { name: 'Fire "load" event', _end: 2874, _start: 2852 }115 ])116 timings.domInteractive = undefined117 spans = navigationTiming.createNavigationTimingSpans(timings, timings.fetchStart)118 expect(spans.map(mapSpan)).toEqual([119 { name: 'Fire "DOMContentLoaded" event', _end: 1498, _start: 1464 },120 { name: 'Fire "load" event', _end: 2874, _start: 2852 }121 ])122 timings.domInteractive = 0123 spans = navigationTiming.createNavigationTimingSpans(timings, timings.fetchStart)124 expect(spans.map(mapSpan)).toEqual([125 { name: 'Fire "DOMContentLoaded" event', _end: 1498, _start: 1464 },126 { name: 'Fire "load" event', _end: 2874, _start: 2852 }127 ])128 timings.domInteractive = 1129 spans = navigationTiming.createNavigationTimingSpans(timings, timings.fetchStart)130 expect(spans.map(mapSpan)).toEqual([131 { name: 'Fire "DOMContentLoaded" event', _end: 1498, _start: 1464 },132 { name: 'Fire "load" event', _end: 2874, _start: 2852 }133 ])134 timings.domInteractive = Number(new Date())135 spans = navigationTiming.createNavigationTimingSpans(timings, timings.fetchStart)136 expect(spans.map(mapSpan)).toEqual([137 { name: 'Fire "DOMContentLoaded" event', _end: 1498, _start: 1464 },138 { name: 'Fire "load" event', _end: 2874, _start: 2852 }139 ])140 timings.domLoading = null141 timings.domInteractive = null142 spans = navigationTiming.createNavigationTimingSpans(timings, timings.fetchStart)143 expect(spans.map(mapSpan)).toEqual([144 { name: 'Fire "DOMContentLoaded" event', _end: 1498, _start: 1464 },145 { name: 'Fire "load" event', _end: 2874, _start: 2852 }146 ])147 timings.domLoading = undefined148 timings.domInteractive = undefined149 spans = navigationTiming.createNavigationTimingSpans(timings, timings.fetchStart)150 expect(spans.map(mapSpan)).toEqual([151 { name: 'Fire "DOMContentLoaded" event', _end: 1498, _start: 1464 },152 { name: 'Fire "load" event', _end: 2874, _start: 2852 }153 ])154 timings.domLoading = 0155 timings.domInteractive = 0156 spans = navigationTiming.createNavigationTimingSpans(timings, timings.fetchStart)157 expect(spans.map(mapSpan)).toEqual([158 { name: 'Fire "DOMContentLoaded" event', _end: 1498, _start: 1464 },159 { name: 'Fire "load" event', _end: 2874, _start: 2852 }160 ])161 timings.domLoading = 1162 timings.domInteractive = 1163 spans = navigationTiming.createNavigationTimingSpans(timings, timings.fetchStart)164 expect(spans.map(mapSpan)).toEqual([165 { name: 'Fire "DOMContentLoaded" event', _end: 1498, _start: 1464 },166 { name: 'Fire "load" event', _end: 2874, _start: 2852 }167 ])168 timings.domLoading = Number(new Date())169 timings.domInteractive = Number(new Date())170 spans = navigationTiming.createNavigationTimingSpans(timings, timings.fetchStart)171 expect(spans.map(mapSpan)).toEqual([172 { name: 'Fire "DOMContentLoaded" event', _end: 1498, _start: 1464 },173 { name: 'Fire "load" event', _end: 2874, _start: 2852 }174 ])175 timings.domContentLoadedEventStart = 'testing'176 timings.domContentLoadedEventEnd = 'testings'177 spans = navigationTiming.createNavigationTimingSpans(timings, timings.fetchStart)178 expect(spans.map(mapSpan)).toEqual([{ name: 'Fire "load" event', _end: 2874, _start: 2852 }])179 // console.log(spans.map(s => `${s._start}, ${s._end}, ${s.duration()}, ${s.name}`).join('\n'))180 })181 it('should createResourceTimingSpans', function () {182 var spans = navigationTiming.createResourceTimingSpans(resourceEntries, [])183 expect(spans.map(mapSpan)).toEqual(spanSnapshot)184 })185 it('should captureHardNavigation', function () {186 var tr = new Transaction('test', 'test')187 tr.isHardNavigation = true188 tr.end()189 navigationTiming.captureHardNavigation(tr)190 expect(tr.spans.length).toBeGreaterThan(1)191 })...

Full Screen

Full Screen

deque.js

Source:deque.js Github

copy

Full Screen

1class Deque {2 constructor() {3 this._start = null4 this._end = null5 this._size = 06 }7 get size() {8 return this._size9 }10 push(el) {11 if (this._start === null) {12 const newNode = new Node(el, null, null)13 this._start = newNode14 this._end = newNode15 } else {16 const newNode = new Node(el, this._end, null)17 this._end.next = newNode18 this._end = newNode19 }20 this._size++21 }22 pop() {23 if (this._end === null) {24 return null25 }26 const removeElem = this._end27 this._end = removeElem.prev28 if (this._end === null) {29 this._start = null30 } else {31 this._end.next = null32 }33 this._size--34 return removeElem.val35 }36 unshift(el) {37 if (this._start === null) {38 const newNode = new Node(el, null, null)39 this._start = newNode40 this._end = newNode41 } else {42 const newNode = new Node(el, null, this._start)43 this._start.prev = newNode44 this._start = newNode45 }46 this._size++47 }48 shift() {49 if (this._start === null) {50 return null51 }52 const removeElem = this._start53 this._start = removeElem.next54 if (this._start === null) {55 this._end = null56 } else {57 this._start.prev = null58 }59 this._size--60 return removeElem.val61 }62 forEach(fn) {63 if (this._start === null) {64 return65 }66 let currentElem = this._start67 while (currentElem !== null) {68 fn(currentElem.val)69 currentElem = currentElem.next70 }71 }72 toArray() {73 if (this._start === null) {74 return []75 }76 let current = this._start77 let index = 078 const result = Array(this._size)79 while (current) {80 result[index] = current.val81 current = current.next82 index++83 }84 return result85 }86}87class Node {88 constructor(val, prev, next) {89 this.val = val90 this.prev = prev91 this.next = next92 }93}...

Full Screen

Full Screen

dategeneration.js

Source:dategeneration.js Github

copy

Full Screen

1/*2const { format, setDayOfYear } = require("date-fns");3function generateDate(duration) {4 let START = new Date(2022, 0, 1);5 let _start = START;6 let _end;7 let datesArr = [];8 for (let i = 1; i <= 365; i = i + duration) {9 let obj = {};10 obj.start = format(_start, "dd/MM/yyyy");11 _end = new Date(setDayOfYear(START, duration + i));12 obj.end = format(_end, "dd/MM/yyyy");13 _start = _end;14 datesArr.push(obj);15 }16 return datesArr;17}18console.log(generateDate(30));19//console.log(generateDate(14).length);20/*21const { format, setDayOfYear } = require("date-fns");22function generateDate(duration, skip = []){23 let START = new Date(2022, 0, 1);24 let _start = START;25 let _end;26 let datesArr = [];27 let i=1;28 while (i <= 365 ) {29 let obj = {};30 if (!skip.includes(_start.getDay())) {31 obj.start = format(_start, "dd/MM/yyyy");32 _end = new Date(setDayOfYear(START, duration + i));33 obj.end = format(_end, "dd/MM/yyyy");34 datesArr.push(obj);35 _start = _end;36 i = i + duration37 }else{38 _start = new Date(setDayOfYear(START, i));39 i=i+1;40 }41 42 }43 console.log(datesArr);44 console.log(datesArr.length);45}46generateDate(14, [0, 6]);47*/48const { format, setDayOfYear } = require("date-fns");49function generateDateMonthly(duration) {50 let START = new Date(2022, 0, 1);51 let _start = START;52 let _end;53 let datesArr = [];54 for (let i = 1; i <= 365; i = i + duration) {55 let obj = {};56 obj.start = format(_start, "dd/MM/yyyy");57 _end = new Date(setDayOfYear(START, duration + i));58 obj.end = format(_end, "dd/MM/yyyy");59 _start = _end;60 datesArr.push(obj);61 }62 return datesArr;...

Full Screen

Full Screen

timer.js

Source:timer.js Github

copy

Full Screen

1var Timer = (function () {2 function Timer () {3 this._start = [0, 0];4 this._end = [0, 0];5 }6 Timer.prototype.start = function () {7 this._start = process.hrtime();8 return this;9 };10 Timer.prototype.stop = function () {11 this._end = process.hrtime(this._start);12 return this;13 };14 Timer.prototype.seconds = function () {15 return this._end[0] + (this._end[1] / 1000000000);16 };17 Timer.prototype.milliseconds = function () {18 return (this._end[0] * 1000) + (this._end[1] / 1000000);19 };20 Timer.prototype.microseconds = function () {21 return (this._end[0] * 1000000) + (this._end[1] / 1000);22 };23 return Timer;24} ());...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', () => {2 it('Visits the Kitchen Sink', () => {3 cy.pause()4 cy.contains('type').click()5 cy.url().should('include', '/commands/actions')6 cy.get('.action-email')7 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.overwrite('end', () => {2 cy._end();3});4Cypress.Commands.overwrite('end', () => {5 cy._end();6});7Cypress.Commands.overwrite('end', () => {8 cy._end();9});10Cypress.Commands.overwrite('end', () => {11 cy._end();12});13Cypress.Commands.overwrite('end', () => {14 cy._end();15});16Cypress.Commands.overwrite('end', () => {17 cy._end();18});19Cypress.Commands.overwrite('end', () => {20 cy._end();21});22Cypress.Commands.overwrite('end', () => {23 cy._end();24});25Cypress.Commands.overwrite('end', () => {26 cy._end();27});28Cypress.Commands.overwrite('end', () => {29 cy._end();30});31Cypress.Commands.overwrite('end', () => {32 cy._end();

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.get('#myInput').type('Hello World').then(($input) => {2 $input[0]._end()3})4cy.get('#myInput').type('Hello World').then(($input) => {5 $input[0]._key('enter')6})7cy.get('#myInput').type('Hello World').then(($input) => {8 $input[0]._key('enter')9})10cy.get('#myInput').type('Hello World').then(($input) => {11 $input[0]._key('enter')12})13cy.get('#myInput').type('Hello World').then(($input) => {14 $input[0]._key('enter')15})16cy.get('#myInput').type('Hello World').then(($input) => {17 $input[0]._key('enter')18})19cy.get('#myInput').type('Hello World').then(($input) => {20 $input[0]._key('enter')21})22cy.get('#myInput').type('Hello World').then(($input) => {23 $input[0]._key('enter')24})25cy.get('#myInput').type('Hello World').then(($input) => {26 $input[0]._key('enter')27})28cy.get('#myInput').type('Hello World').then(($input) => {29 $input[0]._key('enter')30})31cy.get('#myInput').type('Hello World').then(($input) => {32 $input[0]._key('enter')33})34cy.get('#myInput').type('Hello World').then(($input) => {35 $input[0]._key('enter')36})37cy.get('#myInput').type('Hello World').then(($input) => {38 $input[0]._key('enter')39})40cy.get('#myInput').type

Full Screen

Using AI Code Generation

copy

Full Screen

1 expect(response.status).to.eq(200)2 response._end()3})4 expect(response.status).to.eq(200)5 response._end()6})7 expect(response.status).to.eq(200)8 response._end()9})10 expect(response.status).to.eq(200)11 response._end()12})13 expect(response.status).to.eq(200)14 response._end()15})16 expect(response.status).to.eq(200)17 response._end()18})19 expect(response.status).to.eq(200)20 response._end()21})22 expect(response.status).to.eq(200)23 response._end()24})25 expect(response.status).to.eq(200)26 response._end()27})28 expect(response.status).to.eq(200)29 response._end()30})31 expect(response.status).to.eq(200)

Full Screen

Using AI Code Generation

copy

Full Screen

1after(function() {2 cy.end()3})4describe('My First Test', function() {5 it('Does not do much!', function() {6 expect(true).to.equal(true)7 })8})

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful