Best JavaScript code snippet using playwright-internal
svg-pan-zoom.min.js
Source: svg-pan-zoom.min.js
...46 },47 _createZoomIn: function(t) {48 var e = document.createElementNS(o.svgNS, "g");49 e.setAttribute("id", "svg-pan-zoom-zoom-in"), e.setAttribute("transform", "translate(30.5 5) scale(0.015)"), e.setAttribute("class", "svg-pan-zoom-control"), e.addEventListener("click", function() {50 t.getPublicInstance().zoomIn()51 }, !1), e.addEventListener("touchstart", function() {52 t.getPublicInstance().zoomIn()53 }, !1);54 var n = document.createElementNS(o.svgNS, "rect");55 n.setAttribute("x", "0"), n.setAttribute("y", "0"), n.setAttribute("width", "1500"), n.setAttribute("height", "1400"), n.setAttribute("class", "svg-pan-zoom-control-background"), e.appendChild(n);56 var i = document.createElementNS(o.svgNS, "path");57 return i.setAttribute("d", "M1280 576v128q0 26 -19 45t-45 19h-320v320q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-320h-320q-26 0 -45 -19t-19 -45v-128q0 -26 19 -45t45 -19h320v-320q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v320h320q26 0 45 19t19 45zM1536 1120v-960 q0 -119 -84.5 -203.5t-203.5 -84.5h-960q-119 0 -203.5 84.5t-84.5 203.5v960q0 119 84.5 203.5t203.5 84.5h960q119 0 203.5 -84.5t84.5 -203.5z"), i.setAttribute("class", "svg-pan-zoom-control-element"), e.appendChild(i), e58 },59 _createZoomReset: function(t) {60 var e = document.createElementNS(o.svgNS, "g");61 e.setAttribute("id", "svg-pan-zoom-reset-pan-zoom"), e.setAttribute("transform", "translate(5 35) scale(0.4)"), e.setAttribute("class", "svg-pan-zoom-control"), e.addEventListener("click", function() {62 t.getPublicInstance().reset()63 }, !1), e.addEventListener("touchstart", function() {64 t.getPublicInstance().reset()65 }, !1);66 var n = document.createElementNS(o.svgNS, "rect");67 n.setAttribute("x", "2"), n.setAttribute("y", "2"), n.setAttribute("width", "182"), n.setAttribute("height", "58"), n.setAttribute("class", "svg-pan-zoom-control-background"), e.appendChild(n);68 var i = document.createElementNS(o.svgNS, "path");69 i.setAttribute("d", "M33.051,20.632c-0.742-0.406-1.854-0.609-3.338-0.609h-7.969v9.281h7.769c1.543,0,2.701-0.188,3.473-0.562c1.365-0.656,2.048-1.953,2.048-3.891C35.032,22.757,34.372,21.351,33.051,20.632z"), i.setAttribute("class", "svg-pan-zoom-control-element"), e.appendChild(i);70 var s = document.createElementNS(o.svgNS, "path");71 return s.setAttribute("d", "M170.231,0.5H15.847C7.102,0.5,0.5,5.708,0.5,11.84v38.861C0.5,56.833,7.102,61.5,15.847,61.5h154.384c8.745,0,15.269-4.667,15.269-10.798V11.84C185.5,5.708,178.976,0.5,170.231,0.5z M42.837,48.569h-7.969c-0.219-0.766-0.375-1.383-0.469-1.852c-0.188-0.969-0.289-1.961-0.305-2.977l-0.047-3.211c-0.03-2.203-0.41-3.672-1.142-4.406c-0.732-0.734-2.103-1.102-4.113-1.102h-7.05v13.547h-7.055V14.022h16.524c2.361,0.047,4.178,0.344,5.45,0.891c1.272,0.547,2.351,1.352,3.234,2.414c0.731,0.875,1.31,1.844,1.737,2.906s0.64,2.273,0.64,3.633c0,1.641-0.414,3.254-1.242,4.84s-2.195,2.707-4.102,3.363c1.594,0.641,2.723,1.551,3.387,2.73s0.996,2.98,0.996,5.402v2.32c0,1.578,0.063,2.648,0.19,3.211c0.19,0.891,0.635,1.547,1.333,1.969V48.569z M75.579,48.569h-26.18V14.022h25.336v6.117H56.454v7.336h16.781v6H56.454v8.883h19.125V48.569z M104.497,46.331c-2.44,2.086-5.887,3.129-10.34,3.129c-4.548,0-8.125-1.027-10.731-3.082s-3.909-4.879-3.909-8.473h6.891c0.224,1.578,0.662,2.758,1.316,3.539c1.196,1.422,3.246,2.133,6.15,2.133c1.739,0,3.151-0.188,4.236-0.562c2.058-0.719,3.087-2.055,3.087-4.008c0-1.141-0.504-2.023-1.512-2.648c-1.008-0.609-2.607-1.148-4.796-1.617l-3.74-0.82c-3.676-0.812-6.201-1.695-7.576-2.648c-2.328-1.594-3.492-4.086-3.492-7.477c0-3.094,1.139-5.664,3.417-7.711s5.623-3.07,10.036-3.07c3.685,0,6.829,0.965,9.431,2.895c2.602,1.93,3.966,4.73,4.093,8.402h-6.938c-0.128-2.078-1.057-3.555-2.787-4.43c-1.154-0.578-2.587-0.867-4.301-0.867c-1.907,0-3.428,0.375-4.565,1.125c-1.138,0.75-1.706,1.797-1.706,3.141c0,1.234,0.561,2.156,1.682,2.766c0.721,0.406,2.25,0.883,4.589,1.43l6.063,1.43c2.657,0.625,4.648,1.461,5.975,2.508c2.059,1.625,3.089,3.977,3.089,7.055C108.157,41.624,106.937,44.245,104.497,46.331z M139.61,48.569h-26.18V14.022h25.336v6.117h-18.281v7.336h16.781v6h-16.781v8.883h19.125V48.569z M170.337,20.14h-10.336v28.43h-7.266V20.14h-10.383v-6.117h27.984V20.14z"), s.setAttribute("class", "svg-pan-zoom-control-element"), e.appendChild(s), e72 },73 _createZoomOut: function(t) {74 var e = document.createElementNS(o.svgNS, "g");75 e.setAttribute("id", "svg-pan-zoom-zoom-out"), e.setAttribute("transform", "translate(30.5 70) scale(0.015)"), e.setAttribute("class", "svg-pan-zoom-control"), e.addEventListener("click", function() {76 t.getPublicInstance().zoomOut()77 }, !1), e.addEventListener("touchstart", function() {78 t.getPublicInstance().zoomOut()79 }, !1);80 var n = document.createElementNS(o.svgNS, "rect");81 n.setAttribute("x", "0"), n.setAttribute("y", "0"), n.setAttribute("width", "1500"), n.setAttribute("height", "1400"), n.setAttribute("class", "svg-pan-zoom-control-background"), e.appendChild(n);82 var i = document.createElementNS(o.svgNS, "path");83 return i.setAttribute("d", "M1280 576v128q0 26 -19 45t-45 19h-896q-26 0 -45 -19t-19 -45v-128q0 -26 19 -45t45 -19h896q26 0 45 19t19 45zM1536 1120v-960q0 -119 -84.5 -203.5t-203.5 -84.5h-960q-119 0 -203.5 84.5t-84.5 203.5v960q0 119 84.5 203.5t203.5 84.5h960q119 0 203.5 -84.5 t84.5 -203.5z"), i.setAttribute("class", "svg-pan-zoom-control-element"), e.appendChild(i), e84 },85 disable: function(t) {86 t.controlIcons && (t.controlIcons.parentNode.removeChild(t.controlIcons), t.controlIcons = null)87 }88 }89 }, {90 "./svg-utilities": 591 }],92 3: [function(t, e) {93 var o = t("./svg-utilities"),94 n = t("./utilities"),95 i = function(t, e) {96 this.init(t, e)97 };98 i.prototype.init = function(t, e) {99 this.viewport = t, this.options = e, this.originalState = {100 zoom: 1,101 x: 0,102 y: 0103 }, this.activeState = {104 zoom: 1,105 x: 0,106 y: 0107 }, this.updateCTMCached = n.proxy(this.updateCTM, this), this.requestAnimationFrame = n.createRequestAnimationFrame(this.options.refreshRate), this.viewBox = {108 x: 0,109 y: 0,110 width: 0,111 height: 0112 }, this.cacheViewBox(), this.processCTM(), this.updateCTM()113 }, i.prototype.cacheViewBox = function() {114 var t = this.options.svg.getAttribute("viewBox");115 if (t) {116 var e = t.split(/[\s\,]/).filter(function(t) {117 return t118 }).map(parseFloat);119 this.viewBox.x = e[0], this.viewBox.y = e[1], this.viewBox.width = e[2], this.viewBox.height = e[3];120 var o = Math.min(this.options.width / this.viewBox.width, this.options.height / this.viewBox.height);121 this.activeState.zoom = o, this.activeState.x = (this.options.width - this.viewBox.width * o) / 2, this.activeState.y = (this.options.height - this.viewBox.height * o) / 2, this.updateCTMOnNextFrame(), this.options.svg.removeAttribute("viewBox")122 } else {123 var n = this.viewport.getBBox();124 this.viewBox.x = n.x, this.viewBox.y = n.y, this.viewBox.width = n.width, this.viewBox.height = n.height125 }126 }, i.prototype.recacheViewBox = function() {127 var t = this.viewport.getBoundingClientRect(),128 e = t.width / this.getZoom(),129 o = t.height / this.getZoom();130 this.viewBox.x = 0, this.viewBox.y = 0, this.viewBox.width = e, this.viewBox.height = o131 }, i.prototype.getViewBox = function() {132 return n.extend({}, this.viewBox)133 }, i.prototype.processCTM = function() {134 var t = this.getCTM();135 if (this.options.fit || this.options.contain) {136 var e;137 e = this.options.fit ? Math.min(this.options.width / this.viewBox.width, this.options.height / this.viewBox.height) : Math.max(this.options.width / this.viewBox.width, this.options.height / this.viewBox.height), t.a = e, t.d = e, t.e = -this.viewBox.x * e, t.f = -this.viewBox.y * e138 }139 if (this.options.center) {140 var o = .5 * (this.options.width - (this.viewBox.width + 2 * this.viewBox.x) * t.a),141 n = .5 * (this.options.height - (this.viewBox.height + 2 * this.viewBox.y) * t.a);142 t.e = o, t.f = n143 }144 this.originalState.zoom = t.a, this.originalState.x = t.e, this.originalState.y = t.f, this.setCTM(t)145 }, i.prototype.getOriginalState = function() {146 return n.extend({}, this.originalState)147 }, i.prototype.getState = function() {148 return n.extend({}, this.activeState)149 }, i.prototype.getZoom = function() {150 return this.activeState.zoom151 }, i.prototype.getRelativeZoom = function() {152 return this.activeState.zoom / this.originalState.zoom153 }, i.prototype.computeRelativeZoom = function(t) {154 return t / this.originalState.zoom155 }, i.prototype.getPan = function() {156 return {157 x: this.activeState.x,158 y: this.activeState.y159 }160 }, i.prototype.getCTM = function() {161 var t = this.options.svg.createSVGMatrix();162 return t.a = this.activeState.zoom, t.b = 0, t.c = 0, t.d = this.activeState.zoom, t.e = this.activeState.x, t.f = this.activeState.y, t163 }, i.prototype.setCTM = function(t) {164 var e = this.isZoomDifferent(t),165 o = this.isPanDifferent(t);166 if (e || o) {167 if (e && this.options.beforeZoom(this.getRelativeZoom(), this.computeRelativeZoom(t.a)) === !1 && (t.a = t.d = this.activeState.zoom, e = !1), o) {168 var i = this.options.beforePan(this.getPan(), {169 x: t.e,170 y: t.f171 }),172 s = !1,173 r = !1;174 i === !1 ? (t.e = this.getPan().x, t.f = this.getPan().y, s = r = !0) : n.isObject(i) && (i.x === !1 ? (t.e = this.getPan().x, s = !0) : n.isNumber(i.x) && (t.e = i.x), i.y === !1 ? (t.f = this.getPan().y, r = !0) : n.isNumber(i.y) && (t.f = i.y)), s && r && (o = !1)175 }(e || o) && (this.updateCache(t), this.updateCTMOnNextFrame(), e && this.options.onZoom(this.getRelativeZoom()), o && this.options.onPan(this.getPan()))176 }177 }, i.prototype.isZoomDifferent = function(t) {178 return this.activeState.zoom !== t.a179 }, i.prototype.isPanDifferent = function(t) {180 return this.activeState.x !== t.e || this.activeState.y !== t.f181 }, i.prototype.updateCache = function(t) {182 this.activeState.zoom = t.a, this.activeState.x = t.e, this.activeState.y = t.f183 }, i.prototype.pendingUpdate = !1, i.prototype.updateCTMOnNextFrame = function() {184 this.pendingUpdate || (this.pendingUpdate = !0, this.requestAnimationFrame.call(window, this.updateCTMCached))185 }, i.prototype.updateCTM = function() {186 o.setCTM(this.viewport, this.getCTM(), this.defs), this.pendingUpdate = !1187 }, e.exports = function(t, e) {188 return new i(t, e)189 }190 }, {191 "./svg-utilities": 5,192 "./utilities": 7193 }],194 4: [function(t, e) {195 var o = t("./uniwheel"),196 n = t("./control-icons"),197 i = t("./utilities"),198 s = t("./svg-utilities"),199 r = t("./shadow-viewport"),200 a = function(t, e) {201 this.init(t, e)202 },203 l = {204 viewportSelector: ".svg-pan-zoom_viewport",205 panEnabled: !0,206 controlIconsEnabled: !1,207 zoomEnabled: !0,208 dblClickZoomEnabled: !0,209 mouseWheelZoomEnabled: !0,210 preventMouseEventsDefault: !0,211 zoomScaleSensitivity: .1,212 minZoom: .5,213 maxZoom: 10,214 fit: !0,215 contain: !1,216 center: !0,217 refreshRate: "auto",218 beforeZoom: null,219 onZoom: null,220 beforePan: null,221 onPan: null,222 customEventsHandler: null,223 eventsListenerElement: null224 };225 a.prototype.init = function(t, e) {226 var o = this;227 this.svg = t, this.defs = t.querySelector("defs"), s.setupSvgAttributes(this.svg), this.options = i.extend(i.extend({}, l), e), this.state = "none";228 var a = s.getBoundingClientRectNormalized(t);229 this.width = a.width, this.height = a.height, this.viewport = r(s.getOrCreateViewport(this.svg, this.options.viewportSelector), {230 svg: this.svg,231 width: this.width,232 height: this.height,233 fit: this.options.fit,234 contain: this.options.contain,235 center: this.options.center,236 refreshRate: this.options.refreshRate,237 beforeZoom: function(t, e) {238 return o.viewport && o.options.beforeZoom ? o.options.beforeZoom(t, e) : void 0239 },240 onZoom: function(t) {241 return o.viewport && o.options.onZoom ? o.options.onZoom(t) : void 0242 },243 beforePan: function(t, e) {244 return o.viewport && o.options.beforePan ? o.options.beforePan(t, e) : void 0245 },246 onPan: function(t) {247 return o.viewport && o.options.onPan ? o.options.onPan(t) : void 0248 }249 });250 var u = this.getPublicInstance();251 u.setBeforeZoom(this.options.beforeZoom), u.setOnZoom(this.options.onZoom), u.setBeforePan(this.options.beforePan), u.setOnPan(this.options.onPan), this.options.controlIconsEnabled && n.enable(this), this.lastMouseWheelEventTime = Date.now(), this.setupHandlers()252 }, a.prototype.setupHandlers = function() {253 var t = this,254 e = null;255 if (this.eventListeners = {256 mousedown: function(e) {257 return t.handleMouseDown(e, null)258 },259 touchstart: function(o) {260 var n = t.handleMouseDown(o, e);261 return e = o, n262 },263 mouseup: function(e) {264 return t.handleMouseUp(e)265 },266 touchend: function(e) {267 return t.handleMouseUp(e)268 },269 mousemove: function(e) {270 return t.handleMouseMove(e)271 },272 touchmove: function(e) {273 return t.handleMouseMove(e)274 },275 mouseleave: function(e) {276 return t.handleMouseUp(e)277 },278 touchleave: function(e) {279 return t.handleMouseUp(e)280 },281 touchcancel: function(e) {282 return t.handleMouseUp(e)283 }284 }, null != this.options.customEventsHandler) {285 this.options.customEventsHandler.init({286 svgElement: this.svg,287 eventsListenerElement: this.options.eventsListenerElement,288 instance: this.getPublicInstance()289 });290 var o = this.options.customEventsHandler.haltEventListeners;291 if (o && o.length)292 for (var n = o.length - 1; n >= 0; n--) this.eventListeners.hasOwnProperty(o[n]) && delete this.eventListeners[o[n]]293 }294 for (var i in this.eventListeners)(this.options.eventsListenerElement || this.svg).addEventListener(i, this.eventListeners[i], !1);295 this.options.mouseWheelZoomEnabled && (this.options.mouseWheelZoomEnabled = !1, this.enableMouseWheelZoom())296 }, a.prototype.enableMouseWheelZoom = function() {297 if (!this.options.mouseWheelZoomEnabled) {298 var t = this;299 this.wheelListener = function(e) {300 return t.handleMouseWheel(e)301 }, o.on(this.options.eventsListenerElement || this.svg, this.wheelListener, !1), this.options.mouseWheelZoomEnabled = !0302 }303 }, a.prototype.disableMouseWheelZoom = function() {304 this.options.mouseWheelZoomEnabled && (o.off(this.options.eventsListenerElement || this.svg, this.wheelListener, !1), this.options.mouseWheelZoomEnabled = !1)305 }, a.prototype.handleMouseWheel = function(t) {306 if (this.options.zoomEnabled && "none" === this.state) {307 this.options.preventMouseEventsDefault && (t.preventDefault ? t.preventDefault() : t.returnValue = !1);308 var e = t.deltaY || 1,309 o = Date.now() - this.lastMouseWheelEventTime,310 n = 3 + Math.max(0, 30 - o);311 this.lastMouseWheelEventTime = Date.now(), "deltaMode" in t && 0 === t.deltaMode && t.wheelDelta && (e = 0 === t.deltaY ? 0 : Math.abs(t.wheelDelta) / t.deltaY), e = e > -.3 && .3 > e ? e : (e > 0 ? 1 : -1) * Math.log(Math.abs(e) + 10) / n;312 var i = this.svg.getScreenCTM().inverse(),313 r = s.getEventPoint(t, this.svg).matrixTransform(i),314 a = Math.pow(1 + this.options.zoomScaleSensitivity, -1 * e);315 this.zoomAtPoint(a, r)316 }317 }, a.prototype.zoomAtPoint = function(t, e, o) {318 var n = this.viewport.getOriginalState();319 o ? (t = Math.max(this.options.minZoom * n.zoom, Math.min(this.options.maxZoom * n.zoom, t)), t /= this.getZoom()) : this.getZoom() * t < this.options.minZoom * n.zoom ? t = this.options.minZoom * n.zoom / this.getZoom() : this.getZoom() * t > this.options.maxZoom * n.zoom && (t = this.options.maxZoom * n.zoom / this.getZoom());320 var i = this.viewport.getCTM(),321 s = e.matrixTransform(i.inverse()),322 r = this.svg.createSVGMatrix().translate(s.x, s.y).scale(t).translate(-s.x, -s.y),323 a = i.multiply(r);324 a.a !== i.a && this.viewport.setCTM(a)325 }, a.prototype.zoom = function(t, e) {326 this.zoomAtPoint(t, s.getSvgCenterPoint(this.svg, this.width, this.height), e)327 }, a.prototype.publicZoom = function(t, e) {328 e && (t = this.computeFromRelativeZoom(t)), this.zoom(t, e)329 }, a.prototype.publicZoomAtPoint = function(t, e, o) {330 if (o && (t = this.computeFromRelativeZoom(t)), !("SVGPoint" !== i.getType(e) && "x" in e && "y" in e)) throw new Error("Given point is invalid");331 e = s.createSVGPoint(this.svg, e.x, e.y), this.zoomAtPoint(t, e, o)332 }, a.prototype.getZoom = function() {333 return this.viewport.getZoom()334 }, a.prototype.getRelativeZoom = function() {335 return this.viewport.getRelativeZoom()336 }, a.prototype.computeFromRelativeZoom = function(t) {337 return t * this.viewport.getOriginalState().zoom338 }, a.prototype.resetZoom = function() {339 var t = this.viewport.getOriginalState();340 this.zoom(t.zoom, !0)341 }, a.prototype.resetPan = function() {342 this.pan(this.viewport.getOriginalState())343 }, a.prototype.reset = function() {344 this.resetZoom(), this.resetPan()345 }, a.prototype.handleDblClick = function(t) {346 if (this.options.preventMouseEventsDefault && (t.preventDefault ? t.preventDefault() : t.returnValue = !1), this.options.controlIconsEnabled) {347 var e = t.target.getAttribute("class") || "";348 if (e.indexOf("svg-pan-zoom-control") > -1) return !1349 }350 var o;351 o = t.shiftKey ? 1 / (2 * (1 + this.options.zoomScaleSensitivity)) : 2 * (1 + this.options.zoomScaleSensitivity);352 var n = s.getEventPoint(t, this.svg).matrixTransform(this.svg.getScreenCTM().inverse());353 this.zoomAtPoint(o, n)354 }, a.prototype.handleMouseDown = function(t, e) {355 this.options.preventMouseEventsDefault && (t.preventDefault ? t.preventDefault() : t.returnValue = !1), i.mouseAndTouchNormalize(t, this.svg), this.options.dblClickZoomEnabled && i.isDblClick(t, e) ? this.handleDblClick(t) : (this.state = "pan", this.firstEventCTM = this.viewport.getCTM(), this.stateOrigin = s.getEventPoint(t, this.svg).matrixTransform(this.firstEventCTM.inverse()))356 }, a.prototype.handleMouseMove = function(t) {357 if (this.options.preventMouseEventsDefault && (t.preventDefault ? t.preventDefault() : t.returnValue = !1), "pan" === this.state && this.options.panEnabled) {358 var e = s.getEventPoint(t, this.svg).matrixTransform(this.firstEventCTM.inverse()),359 o = this.firstEventCTM.translate(e.x - this.stateOrigin.x, e.y - this.stateOrigin.y);360 this.viewport.setCTM(o)361 }362 }, a.prototype.handleMouseUp = function(t) {363 this.options.preventMouseEventsDefault && (t.preventDefault ? t.preventDefault() : t.returnValue = !1), "pan" === this.state && (this.state = "none")364 }, a.prototype.fit = function() {365 var t = this.viewport.getViewBox(),366 e = Math.min(this.width / t.width, this.height / t.height);367 this.zoom(e, !0)368 }, a.prototype.contain = function() {369 var t = this.viewport.getViewBox(),370 e = Math.max(this.width / t.width, this.height / t.height);371 this.zoom(e, !0)372 }, a.prototype.center = function() {373 var t = this.viewport.getViewBox(),374 e = .5 * (this.width - (t.width + 2 * t.x) * this.getZoom()),375 o = .5 * (this.height - (t.height + 2 * t.y) * this.getZoom());376 this.getPublicInstance().pan({377 x: e,378 y: o379 })380 }, a.prototype.updateBBox = function() {381 this.viewport.recacheViewBox()382 }, a.prototype.pan = function(t) {383 var e = this.viewport.getCTM();384 e.e = t.x, e.f = t.y, this.viewport.setCTM(e)385 }, a.prototype.panBy = function(t) {386 var e = this.viewport.getCTM();387 e.e += t.x, e.f += t.y, this.viewport.setCTM(e)388 }, a.prototype.getPan = function() {389 var t = this.viewport.getState();390 return {391 x: t.x,392 y: t.y393 }394 }, a.prototype.resize = function() {395 var t = s.getBoundingClientRectNormalized(this.svg);396 this.width = t.width, this.height = t.height, this.options.controlIconsEnabled && (this.getPublicInstance().disableControlIcons(), this.getPublicInstance().enableControlIcons())397 }, a.prototype.destroy = function() {398 var t = this;399 this.beforeZoom = null, this.onZoom = null, this.beforePan = null, this.onPan = null, null != this.options.customEventsHandler && this.options.customEventsHandler.destroy({400 svgElement: this.svg,401 eventsListenerElement: this.options.eventsListenerElement,402 instance: this.getPublicInstance()403 });404 for (var e in this.eventListeners)(this.options.eventsListenerElement || this.svg).removeEventListener(e, this.eventListeners[e], !1);405 this.disableMouseWheelZoom(), this.getPublicInstance().disableControlIcons(), this.reset(), u = u.filter(function(e) {406 return e.svg !== t.svg407 }), delete this.options, delete this.publicInstance, delete this.pi, this.getPublicInstance = function() {408 return null409 }410 }, a.prototype.getPublicInstance = function() {411 var t = this;412 return this.publicInstance || (this.publicInstance = this.pi = {413 enablePan: function() {414 return t.options.panEnabled = !0, t.pi415 },416 disablePan: function() {417 return t.options.panEnabled = !1, t.pi418 },419 isPanEnabled: function() {420 return !!t.options.panEnabled421 },422 pan: function(e) {423 return t.pan(e), t.pi424 },425 panBy: function(e) {426 return t.panBy(e), t.pi427 },428 getPan: function() {429 return t.getPan()430 },431 setBeforePan: function(e) {432 return t.options.beforePan = null === e ? null : i.proxy(e, t.publicInstance), t.pi433 },434 setOnPan: function(e) {435 return t.options.onPan = null === e ? null : i.proxy(e, t.publicInstance), t.pi436 },437 enableZoom: function() {438 return t.options.zoomEnabled = !0, t.pi439 },440 disableZoom: function() {441 return t.options.zoomEnabled = !1, t.pi442 },443 isZoomEnabled: function() {444 return !!t.options.zoomEnabled445 },446 enableControlIcons: function() {447 return t.options.controlIconsEnabled || (t.options.controlIconsEnabled = !0, n.enable(t)), t.pi448 },449 disableControlIcons: function() {450 return t.options.controlIconsEnabled && (t.options.controlIconsEnabled = !1, n.disable(t)), t.pi451 },452 isControlIconsEnabled: function() {453 return !!t.options.controlIconsEnabled454 },455 enableDblClickZoom: function() {456 return t.options.dblClickZoomEnabled = !0, t.pi457 },458 disableDblClickZoom: function() {459 return t.options.dblClickZoomEnabled = !1, t.pi460 },461 isDblClickZoomEnabled: function() {462 return !!t.options.dblClickZoomEnabled463 },464 enableMouseWheelZoom: function() {465 return t.enableMouseWheelZoom(), t.pi466 },467 disableMouseWheelZoom: function() {468 return t.disableMouseWheelZoom(), t.pi469 },470 isMouseWheelZoomEnabled: function() {471 return !!t.options.mouseWheelZoomEnabled472 },473 setZoomScaleSensitivity: function(e) {474 return t.options.zoomScaleSensitivity = e, t.pi475 },476 setMinZoom: function(e) {477 return t.options.minZoom = e, t.pi478 },479 setMaxZoom: function(e) {480 return t.options.maxZoom = e, t.pi481 },482 setBeforeZoom: function(e) {483 return t.options.beforeZoom = null === e ? null : i.proxy(e, t.publicInstance), t.pi484 },485 setOnZoom: function(e) {486 return t.options.onZoom = null === e ? null : i.proxy(e, t.publicInstance), t.pi487 },488 zoom: function(e) {489 return t.publicZoom(e, !0), t.pi490 },491 zoomBy: function(e) {492 return t.publicZoom(e, !1), t.pi493 },494 zoomAtPoint: function(e, o) {495 return t.publicZoomAtPoint(e, o, !0), t.pi496 },497 zoomAtPointBy: function(e, o) {498 return t.publicZoomAtPoint(e, o, !1), t.pi499 },500 zoomIn: function() {501 return this.zoomBy(1 + t.options.zoomScaleSensitivity), t.pi502 },503 zoomOut: function() {504 return this.zoomBy(1 / (1 + t.options.zoomScaleSensitivity)), t.pi505 },506 getZoom: function() {507 return t.getRelativeZoom()508 },509 resetZoom: function() {510 return t.resetZoom(), t.pi511 },512 resetPan: function() {513 return t.resetPan(), t.pi514 },515 reset: function() {516 return t.reset(), t.pi517 },518 fit: function() {519 return t.fit(), t.pi520 },521 contain: function() {522 return t.contain(), t.pi523 },524 center: function() {525 return t.center(), t.pi526 },527 updateBBox: function() {528 return t.updateBBox(), t.pi529 },530 resize: function() {531 return t.resize(), t.pi532 },533 getSizes: function() {534 return {535 width: t.width,536 height: t.height,537 realZoom: t.getZoom(),538 viewBox: t.viewport.getViewBox()539 }540 },541 destroy: function() {542 return t.destroy(), t.pi543 }544 }), this.publicInstance545 };546 var u = [],547 h = function(t, e) {548 var o = i.getSvg(t);549 if (null === o) return null;550 for (var n = u.length - 1; n >= 0; n--)551 if (u[n].svg === o) return u[n].instance.getPublicInstance();552 return u.push({553 svg: o,554 instance: new a(o, e)555 }), u[u.length - 1].instance.getPublicInstance()556 };557 e.exports = h558 }, {559 "./control-icons": 2,560 "./shadow-viewport": 3,561 "./svg-utilities": 5,562 "./uniwheel": 6,563 "./utilities": 7564 }],565 5: [function(t, e) {566 var o = t("./utilities"),567 n = "unknown";568 document.documentMode && (n = "ie"), e.exports = {569 svgNS: "http://www.w3.org/2000/svg",...
react-pixi.ext.js
Source: react-pixi.ext.js
1/**********************************************************************2 * Extern for ReactPIXI3 * Generated by http://jmmk.github.io/javascript-externs-generator4 **********************************************************************/5var ReactPIXI = {6 "Stage": {7 "displayName": {}8 },9 "DisplayObjectContainer": {10 "displayName": {}11 },12 "SpriteBatch": {13 "displayName": {}14 },15 "Sprite": {16 "displayName": {}17 },18 "Text": {19 "displayName": {}20 },21 "BitmapText": {22 "displayName": {}23 },24 "TilingSprite": {25 "displayName": {}26 },27 "Graphics": {28 "displayName": {}29 },30 "factories": {31 "Stage": {32 "type": {33 "displayName": {}34 }35 },36 "DisplayObjectContainer": {37 "type": {38 "displayName": {}39 }40 },41 "SpriteBatch": {42 "type": {43 "displayName": {}44 }45 },46 "Sprite": {47 "type": {48 "displayName": {}49 }50 },51 "Text": {52 "type": {53 "displayName": {}54 }55 },56 "BitmapText": {57 "type": {58 "displayName": {}59 }60 },61 "TilingSprite": {62 "type": {63 "displayName": {}64 }65 },66 "Graphics": {67 "type": {68 "displayName": {}69 }70 }71 },72 "CustomPIXIComponent": function () {},73 "render": function () {},74 "unmountComponentAtNode": function () {}75};76ReactPIXI.Stage.prototype = {77 "constructor": function () {},78 "__reactAutoBindPairs": function () {},79 "construct": function () {},80 "getPublicInstance": function () {},81 "transferDisplayObjectPropsByName": function () {},82 "applyDisplayObjectProps": function () {},83 "mountComponentIntoNode": function () {},84 "getNativeNode": function () {},85 "_reconcilerInstantiateChildren": function () {},86 "_reconcilerUpdateChildren": function () {},87 "mountChildren": function () {},88 "updateTextContent": function () {},89 "updateMarkup": function () {},90 "updateChildren": function () {},91 "_updateChildren": function () {},92 "unmountChildren": function () {},93 "moveChild": function () {},94 "createChild": function () {},95 "removeChild": function () {},96 "_mountChildAtIndex": function () {},97 "_unmountChild": function () {},98 "mountAndAddChildren": function () {},99 "setApprovedDOMProperties": function () {},100 "generateDefaultRenderer": function () {},101 "componentDidMount": function () {},102 "componentDidUpdate": function () {},103 "componentWillUnmount": function () {},104 "renderStage": function () {},105 "render": function () {},106 "mixins": function () {},107 "statics": function () {},108 "propTypes": function () {},109 "contextTypes": function () {},110 "childContextTypes": function () {},111 "getDefaultProps": function () {},112 "getInitialState": function () {},113 "getChildContext": function () {},114 "componentWillMount": function () {},115 "componentWillReceiveProps": function () {},116 "shouldComponentUpdate": function () {},117 "componentWillUpdate": function () {},118 "updateComponent": function () {},119 "isReactComponent": function () {},120 "setState": function () {},121 "forceUpdate": function () {},122 "replaceState": function () {},123 "isMounted": function () {}124};125ReactPIXI.DisplayObjectContainer.prototype = {126 "construct": function () {},127 "getPublicInstance": function () {},128 "transferDisplayObjectPropsByName": function () {},129 "applyDisplayObjectProps": function () {},130 "mountComponentIntoNode": function () {},131 "getNativeNode": function () {},132 "_reconcilerInstantiateChildren": function () {},133 "_reconcilerUpdateChildren": function () {},134 "mountChildren": function () {},135 "updateTextContent": function () {},136 "updateMarkup": function () {},137 "updateChildren": function () {},138 "_updateChildren": function () {},139 "unmountChildren": function () {},140 "moveChild": function () {},141 "createChild": function () {},142 "removeChild": function () {},143 "_mountChildAtIndex": function () {},144 "_unmountChild": function () {},145 "mountAndAddChildren": function () {},146 "mountComponent": function () {},147 "receiveComponent": function () {},148 "unmountComponent": function () {},149 "createDisplayObject": function () {},150 "applySpecificDisplayObjectProps": function () {}151};152ReactPIXI.SpriteBatch.prototype = {153 "construct": function () {},154 "getPublicInstance": function () {},155 "transferDisplayObjectPropsByName": function () {},156 "applyDisplayObjectProps": function () {},157 "mountComponentIntoNode": function () {},158 "getNativeNode": function () {},159 "_reconcilerInstantiateChildren": function () {},160 "_reconcilerUpdateChildren": function () {},161 "mountChildren": function () {},162 "updateTextContent": function () {},163 "updateMarkup": function () {},164 "updateChildren": function () {},165 "_updateChildren": function () {},166 "unmountChildren": function () {},167 "moveChild": function () {},168 "createChild": function () {},169 "removeChild": function () {},170 "_mountChildAtIndex": function () {},171 "_unmountChild": function () {},172 "mountAndAddChildren": function () {},173 "mountComponent": function () {},174 "receiveComponent": function () {},175 "unmountComponent": function () {},176 "createDisplayObject": function () {},177 "applySpecificDisplayObjectProps": function () {}178};179ReactPIXI.Sprite.prototype = {180 "construct": function () {},181 "getPublicInstance": function () {},182 "transferDisplayObjectPropsByName": function () {},183 "applyDisplayObjectProps": function () {},184 "mountComponentIntoNode": function () {},185 "getNativeNode": function () {},186 "_reconcilerInstantiateChildren": function () {},187 "_reconcilerUpdateChildren": function () {},188 "mountChildren": function () {},189 "updateTextContent": function () {},190 "updateMarkup": function () {},191 "updateChildren": function () {},192 "_updateChildren": function () {},193 "unmountChildren": function () {},194 "moveChild": function () {},195 "createChild": function () {},196 "removeChild": function () {},197 "_mountChildAtIndex": function () {},198 "_unmountChild": function () {},199 "mountAndAddChildren": function () {},200 "mountComponent": function () {},201 "receiveComponent": function () {},202 "unmountComponent": function () {},203 "createDisplayObject": function () {},204 "applySpecificDisplayObjectProps": function () {}205};206ReactPIXI.Text.prototype = {207 "construct": function () {},208 "getPublicInstance": function () {},209 "transferDisplayObjectPropsByName": function () {},210 "applyDisplayObjectProps": function () {},211 "mountComponentIntoNode": function () {},212 "getNativeNode": function () {},213 "_reconcilerInstantiateChildren": function () {},214 "_reconcilerUpdateChildren": function () {},215 "mountChildren": function () {},216 "updateTextContent": function () {},217 "updateMarkup": function () {},218 "updateChildren": function () {},219 "_updateChildren": function () {},220 "unmountChildren": function () {},221 "moveChild": function () {},222 "createChild": function () {},223 "removeChild": function () {},224 "_mountChildAtIndex": function () {},225 "_unmountChild": function () {},226 "mountAndAddChildren": function () {},227 "mountComponent": function () {},228 "receiveComponent": function () {},229 "unmountComponent": function () {},230 "createDisplayObject": function () {},231 "applySpecificDisplayObjectProps": function () {}232};233ReactPIXI.BitmapText.prototype = {234 "construct": function () {},235 "getPublicInstance": function () {},236 "transferDisplayObjectPropsByName": function () {},237 "applyDisplayObjectProps": function () {},238 "mountComponentIntoNode": function () {},239 "getNativeNode": function () {},240 "_reconcilerInstantiateChildren": function () {},241 "_reconcilerUpdateChildren": function () {},242 "mountChildren": function () {},243 "updateTextContent": function () {},244 "updateMarkup": function () {},245 "updateChildren": function () {},246 "_updateChildren": function () {},247 "unmountChildren": function () {},248 "moveChild": function () {},249 "createChild": function () {},250 "removeChild": function () {},251 "_mountChildAtIndex": function () {},252 "_unmountChild": function () {},253 "mountAndAddChildren": function () {},254 "mountComponent": function () {},255 "receiveComponent": function () {},256 "unmountComponent": function () {},257 "createDisplayObject": function () {},258 "applySpecificDisplayObjectProps": function () {}259};260ReactPIXI.TilingSprite.prototype = {261 "construct": function () {},262 "getPublicInstance": function () {},263 "transferDisplayObjectPropsByName": function () {},264 "applyDisplayObjectProps": function () {},265 "mountComponentIntoNode": function () {},266 "getNativeNode": function () {},267 "_reconcilerInstantiateChildren": function () {},268 "_reconcilerUpdateChildren": function () {},269 "mountChildren": function () {},270 "updateTextContent": function () {},271 "updateMarkup": function () {},272 "updateChildren": function () {},273 "_updateChildren": function () {},274 "unmountChildren": function () {},275 "moveChild": function () {},276 "createChild": function () {},277 "removeChild": function () {},278 "_mountChildAtIndex": function () {},279 "_unmountChild": function () {},280 "mountAndAddChildren": function () {},281 "mountComponent": function () {},282 "receiveComponent": function () {},283 "unmountComponent": function () {},284 "createDisplayObject": function () {},285 "applySpecificDisplayObjectProps": function () {}286};287ReactPIXI.Graphics.prototype = {288 "construct": function () {},289 "getPublicInstance": function () {},290 "transferDisplayObjectPropsByName": function () {},291 "applyDisplayObjectProps": function () {},292 "mountComponentIntoNode": function () {},293 "getNativeNode": function () {},294 "_reconcilerInstantiateChildren": function () {},295 "_reconcilerUpdateChildren": function () {},296 "mountChildren": function () {},297 "updateTextContent": function () {},298 "updateMarkup": function () {},299 "updateChildren": function () {},300 "_updateChildren": function () {},301 "unmountChildren": function () {},302 "moveChild": function () {},303 "createChild": function () {},304 "removeChild": function () {},305 "_mountChildAtIndex": function () {},306 "_unmountChild": function () {},307 "mountAndAddChildren": function () {},308 "mountComponent": function () {},309 "receiveComponent": function () {},310 "unmountComponent": function () {},311 "createDisplayObject": function () {},312 "applySpecificDisplayObjectProps": function () {}313};314ReactPIXI.factories.Stage.type.prototype = {315 "constructor": function () {},316 "__reactAutoBindPairs": function () {},317 "construct": function () {},318 "getPublicInstance": function () {},319 "transferDisplayObjectPropsByName": function () {},320 "applyDisplayObjectProps": function () {},321 "mountComponentIntoNode": function () {},322 "getNativeNode": function () {},323 "_reconcilerInstantiateChildren": function () {},324 "_reconcilerUpdateChildren": function () {},325 "mountChildren": function () {},326 "updateTextContent": function () {},327 "updateMarkup": function () {},328 "updateChildren": function () {},329 "_updateChildren": function () {},330 "unmountChildren": function () {},331 "moveChild": function () {},332 "createChild": function () {},333 "removeChild": function () {},334 "_mountChildAtIndex": function () {},335 "_unmountChild": function () {},336 "mountAndAddChildren": function () {},337 "setApprovedDOMProperties": function () {},338 "generateDefaultRenderer": function () {},339 "componentDidMount": function () {},340 "componentDidUpdate": function () {},341 "componentWillUnmount": function () {},342 "renderStage": function () {},343 "render": function () {},344 "mixins": function () {},345 "statics": function () {},346 "propTypes": function () {},347 "contextTypes": function () {},348 "childContextTypes": function () {},349 "getDefaultProps": function () {},350 "getInitialState": function () {},351 "getChildContext": function () {},352 "componentWillMount": function () {},353 "componentWillReceiveProps": function () {},354 "shouldComponentUpdate": function () {},355 "componentWillUpdate": function () {},356 "updateComponent": function () {},357 "isReactComponent": function () {},358 "setState": function () {},359 "forceUpdate": function () {},360 "replaceState": function () {},361 "isMounted": function () {}362};363ReactPIXI.factories.DisplayObjectContainer.type.prototype = {364 "construct": function () {},365 "getPublicInstance": function () {},366 "transferDisplayObjectPropsByName": function () {},367 "applyDisplayObjectProps": function () {},368 "mountComponentIntoNode": function () {},369 "getNativeNode": function () {},370 "_reconcilerInstantiateChildren": function () {},371 "_reconcilerUpdateChildren": function () {},372 "mountChildren": function () {},373 "updateTextContent": function () {},374 "updateMarkup": function () {},375 "updateChildren": function () {},376 "_updateChildren": function () {},377 "unmountChildren": function () {},378 "moveChild": function () {},379 "createChild": function () {},380 "removeChild": function () {},381 "_mountChildAtIndex": function () {},382 "_unmountChild": function () {},383 "mountAndAddChildren": function () {},384 "mountComponent": function () {},385 "receiveComponent": function () {},386 "unmountComponent": function () {},387 "createDisplayObject": function () {},388 "applySpecificDisplayObjectProps": function () {}389};390ReactPIXI.factories.SpriteBatch.type.prototype = {391 "construct": function () {},392 "getPublicInstance": function () {},393 "transferDisplayObjectPropsByName": function () {},394 "applyDisplayObjectProps": function () {},395 "mountComponentIntoNode": function () {},396 "getNativeNode": function () {},397 "_reconcilerInstantiateChildren": function () {},398 "_reconcilerUpdateChildren": function () {},399 "mountChildren": function () {},400 "updateTextContent": function () {},401 "updateMarkup": function () {},402 "updateChildren": function () {},403 "_updateChildren": function () {},404 "unmountChildren": function () {},405 "moveChild": function () {},406 "createChild": function () {},407 "removeChild": function () {},408 "_mountChildAtIndex": function () {},409 "_unmountChild": function () {},410 "mountAndAddChildren": function () {},411 "mountComponent": function () {},412 "receiveComponent": function () {},413 "unmountComponent": function () {},414 "createDisplayObject": function () {},415 "applySpecificDisplayObjectProps": function () {}416};417ReactPIXI.factories.Sprite.type.prototype = {418 "construct": function () {},419 "getPublicInstance": function () {},420 "transferDisplayObjectPropsByName": function () {},421 "applyDisplayObjectProps": function () {},422 "mountComponentIntoNode": function () {},423 "getNativeNode": function () {},424 "_reconcilerInstantiateChildren": function () {},425 "_reconcilerUpdateChildren": function () {},426 "mountChildren": function () {},427 "updateTextContent": function () {},428 "updateMarkup": function () {},429 "updateChildren": function () {},430 "_updateChildren": function () {},431 "unmountChildren": function () {},432 "moveChild": function () {},433 "createChild": function () {},434 "removeChild": function () {},435 "_mountChildAtIndex": function () {},436 "_unmountChild": function () {},437 "mountAndAddChildren": function () {},438 "mountComponent": function () {},439 "receiveComponent": function () {},440 "unmountComponent": function () {},441 "createDisplayObject": function () {},442 "applySpecificDisplayObjectProps": function () {}443};444ReactPIXI.factories.Text.type.prototype = {445 "construct": function () {},446 "getPublicInstance": function () {},447 "transferDisplayObjectPropsByName": function () {},448 "applyDisplayObjectProps": function () {},449 "mountComponentIntoNode": function () {},450 "getNativeNode": function () {},451 "_reconcilerInstantiateChildren": function () {},452 "_reconcilerUpdateChildren": function () {},453 "mountChildren": function () {},454 "updateTextContent": function () {},455 "updateMarkup": function () {},456 "updateChildren": function () {},457 "_updateChildren": function () {},458 "unmountChildren": function () {},459 "moveChild": function () {},460 "createChild": function () {},461 "removeChild": function () {},462 "_mountChildAtIndex": function () {},463 "_unmountChild": function () {},464 "mountAndAddChildren": function () {},465 "mountComponent": function () {},466 "receiveComponent": function () {},467 "unmountComponent": function () {},468 "createDisplayObject": function () {},469 "applySpecificDisplayObjectProps": function () {}470};471ReactPIXI.factories.BitmapText.type.prototype = {472 "construct": function () {},473 "getPublicInstance": function () {},474 "transferDisplayObjectPropsByName": function () {},475 "applyDisplayObjectProps": function () {},476 "mountComponentIntoNode": function () {},477 "getNativeNode": function () {},478 "_reconcilerInstantiateChildren": function () {},479 "_reconcilerUpdateChildren": function () {},480 "mountChildren": function () {},481 "updateTextContent": function () {},482 "updateMarkup": function () {},483 "updateChildren": function () {},484 "_updateChildren": function () {},485 "unmountChildren": function () {},486 "moveChild": function () {},487 "createChild": function () {},488 "removeChild": function () {},489 "_mountChildAtIndex": function () {},490 "_unmountChild": function () {},491 "mountAndAddChildren": function () {},492 "mountComponent": function () {},493 "receiveComponent": function () {},494 "unmountComponent": function () {},495 "createDisplayObject": function () {},496 "applySpecificDisplayObjectProps": function () {}497};498ReactPIXI.factories.TilingSprite.type.prototype = {499 "construct": function () {},500 "getPublicInstance": function () {},501 "transferDisplayObjectPropsByName": function () {},502 "applyDisplayObjectProps": function () {},503 "mountComponentIntoNode": function () {},504 "getNativeNode": function () {},505 "_reconcilerInstantiateChildren": function () {},506 "_reconcilerUpdateChildren": function () {},507 "mountChildren": function () {},508 "updateTextContent": function () {},509 "updateMarkup": function () {},510 "updateChildren": function () {},511 "_updateChildren": function () {},512 "unmountChildren": function () {},513 "moveChild": function () {},514 "createChild": function () {},515 "removeChild": function () {},516 "_mountChildAtIndex": function () {},517 "_unmountChild": function () {},518 "mountAndAddChildren": function () {},519 "mountComponent": function () {},520 "receiveComponent": function () {},521 "unmountComponent": function () {},522 "createDisplayObject": function () {},523 "applySpecificDisplayObjectProps": function () {}524};525ReactPIXI.factories.Graphics.type.prototype = {526 "construct": function () {},527 "getPublicInstance": function () {},528 "transferDisplayObjectPropsByName": function () {},529 "applyDisplayObjectProps": function () {},530 "mountComponentIntoNode": function () {},531 "getNativeNode": function () {},532 "_reconcilerInstantiateChildren": function () {},533 "_reconcilerUpdateChildren": function () {},534 "mountChildren": function () {},535 "updateTextContent": function () {},536 "updateMarkup": function () {},537 "updateChildren": function () {},538 "_updateChildren": function () {},539 "unmountChildren": function () {},540 "moveChild": function () {},541 "createChild": function () {},542 "removeChild": function () {},543 "_mountChildAtIndex": function () {},544 "_unmountChild": function () {},545 "mountAndAddChildren": function () {},546 "mountComponent": function () {},547 "receiveComponent": function () {},548 "unmountComponent": function () {},549 "createDisplayObject": function () {},550 "applySpecificDisplayObjectProps": function () {}551};552/**********************************************************************553 * End Generated Extern for ReactPIXI...
shouldUpdateReactComponent.js
Source: shouldUpdateReactComponent.js
...15 var nextName = null;16 var nextDisplayName = null;17 if ("production" !== process.env.NODE_ENV) {18 if (!ownersMatch) {19 if (prevElement._owner != null && prevElement._owner.getPublicInstance() != null && prevElement._owner.getPublicInstance().constructor != null) {20 prevName = prevElement._owner.getPublicInstance().constructor.displayName;21 }22 if (nextElement._owner != null && nextElement._owner.getPublicInstance() != null && nextElement._owner.getPublicInstance().constructor != null) {23 nextName = nextElement._owner.getPublicInstance().constructor.displayName;24 }25 if (nextElement.type != null && nextElement.type.displayName != null) {26 nextDisplayName = nextElement.type.displayName;27 }28 if (nextElement.type != null && typeof nextElement.type === 'string') {29 nextDisplayName = nextElement.type;30 }31 if (typeof nextElement.type !== 'string' || nextElement.type === 'input' || nextElement.type === 'textarea') {32 if ((prevElement._owner != null && prevElement._owner._isOwnerNecessary === false) || (nextElement._owner != null && nextElement._owner._isOwnerNecessary === false)) {33 if (prevElement._owner != null) {34 prevElement._owner._isOwnerNecessary = true;35 }36 if (nextElement._owner != null) {37 nextElement._owner._isOwnerNecessary = true;...
ReactWWChildOperations.js
Source: ReactWWChildOperations.js
...11 if (typeof child === 'string' || typeof child === 'number') {12 parent.setContent(child);13 } else {14 if (update.toIndex){15 parent.addChildAtIndex(child.getPublicInstance(), update.toIndex);16 } else {17 parent.addChild(child.getPublicInstance());18 }19 }20 }, [MOVE_EXISTING]() {21 console.log(MOVE_EXISTING);22 }, [SET_MARKUP]() {23 console.log(SET_MARKUP);24 }, [TEXT_CONTENT]() {25 console.log(TEXT_CONTENT);26 }, [REMOVE_NODE](update, components) {27 // FIXME - Since this is async, if more than one node from the same parent 28 // Node is to be removed, this causes an error29 update.parentNode.removeChildFromIndex(update.fromIndex);30 }31};32export function processChildrenUpdates(updates, components) {33 for (let i = 0, l = updates.length; i < l; ++i) {34 updates[i].parentNode = ReactWWIDOperations.get(updates[i].parentID);35 let update = updates[i];36 actions[update.type](update, components);37 }38}39export function replaceNodeWithMarkupByID(reactId, markup) {40 // reactId here is the reactId of the old node41 // By the time we are here, the oldNode is already unmounted and hence gone from ReactWWOps42 // ASSUMPTION: The nextNode has the same reactId as the old node43 const nextNode = markup.getPublicInstance();44 nextNode.replaceAt(reactId);...
index.js
Source: index.js
...6 */7var ReactCompositeComponent = require("react/lib/ReactCompositeComponent");8var emptyObject = require("react/lib/emptyObject");9ReactCompositeComponent.Mixin.attachRef = function(ref, component) {10 var inst = this.getPublicInstance();11 var refs = inst.refs === emptyObject ? (inst.refs = {}) : inst.refs;12 var element = component.getPublicInstance();13 if (element.tagName) {14 element = element.getDOMNode();15 // consumers might not realize ref is a DOM element and call getDOMNode()16 element.getDOMNode = function() { return element; }17 }18 refs[ref] = element;...
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const page = await browser.newPage();5 const elementHandle = await page.$('input[name="q"]');6 const publicInstance = elementHandle._getPublicInstance();7 console.log(publicInstance);8 await browser.close();9})();10{ _page: Page { _channel: [Channel] },11 _context: BrowserContext { _channel: [Channel] },12 _channel: Channel {13 _connection: Connection {14 },15 _callbacks: Map(0) {},16 _events: EventEmitter {17 _events: [Object: null prototype] {},
Using AI Code Generation
1const { getPublicInstance } = require('@playwright/test/lib/server/transport');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 const publicPage = getPublicInstance(page);7 console.log(publicPage);8 await browser.close();9})();10Page {11 _page: Page {12 _channel: ChannelOwner {13 _events: [Object: null prototype] {},14 },15 _browserContext: BrowserContext {16 _closePromiseCallback: [Function (anonymous)],17 _didCloseCallback: [Function (anonymous)]18 },19 _workers: Set {},20 _downloads: Set {},21 _timeoutSettings: TimeoutSettings {22 },23 _closedCallback: [Function (anonymous)],24 _didCloseCallback: [Function (anonymous)],25 _closePromise: Promise { <pending> },26 _closePromiseCallback: [Function (anonymous)]27 },28 _closedCallback: [Function (anonymous)],29 _didCloseCallback: [Function (anonymous)],30 _closePromise: Promise { <pending> },31 _closePromiseCallback: [Function (anonymous)]32}
Using AI Code Generation
1const { getPublicInstance } = require('playwright/lib/server/browserType');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const browserType = getPublicInstance(browser);8 console.log(browserType.name());9 await browser.close();10})();11Your name to display (optional):12Your name to display (optional):
Using AI Code Generation
1const { chromium } = require('playwright');2const { getPublicInstance } = require('playwright/lib/server/browserType');3(async () => {4 const browser = await chromium.launch();5 const browserInstance = getPublicInstance(browser);6 console.log(browserInstance);7})();8Browser {9 _browser: Browser {10 _connection: Connection {11 _events: [Object: null prototype] {},12 _callbacks: Map {},13 _sessions: Map {},
Using AI Code Generation
1const { getPublicInstance } = require('playwright/lib/server/browserType');2const webkit = getPublicInstance('webkit');3const browser = await webkit.launch();4const page = await browser.newPage();5await page.screenshot({ path: 'screenshot.png' });6await browser.close();7const { getPublicInstance } = require('playwright/lib/server/browserType');8const webkit = getPublicInstance('webkit');9const browser = await webkit.launch();10const page = await browser.newPage();11await page.screenshot({ path: 'screenshot.png' });12await browser.close();13getPublicInstance(browserType: string) → BrowserType14const { getPublicInstance } = require('playwright/lib/server/browserType');15const webkit = getPublicInstance('webkit');16const browser = await webkit.launch();17const page = await browser.newPage();18await page.screenshot({ path: 'screenshot.png' });19await browser.close();20getPublicInstance('chromium');21getPublicInstance('firefox');22getPublicInstance('webkit');
Using AI Code Generation
1const { getPublicInstance } = require('playwright/lib/server/browserContext');2const { BrowserContext } = require('playwright/lib/server/browserContext');3const { Page } = require('playwright/lib/server/page');4const { ElementHandle } = require('playwright/lib/server/dom');5const context = getPublicInstance(BrowserContext);6const page = getPublicInstance(Page);7const element = getPublicInstance(ElementHandle);8context.newPage().then(page => {9 page.$('input').then(element => {10 element.type('Hello');11 });12});13const { getPublicInstance } = require('playwright/lib/server/browserContext');14const { BrowserContext } = require('playwright/lib/server/browserContext');15const { Page } = require('playwright/lib/server/page');16const { ElementHandle } = require('playwright/lib/server/dom');17const context = getPublicInstance(BrowserContext);18const page = getPublicInstance(Page);19const element = getPublicInstance(ElementHandle);20context.newPage().then(page => {21 page.$('input').then(element => {22 element.type('Hello');23 });24});25const { getPublicInstance } = require('playwright/lib/server/browserContext');26const { BrowserContext } = require('playwright/lib/server/browserContext');27const { Page } = require('playwright/lib/server/page');28const { ElementHandle } = require('playwright/lib/server/dom');29const context = getPublicInstance(BrowserContext);30const page = getPublicInstance(Page);31const element = getPublicInstance(ElementHandle);32context.newPage().then(page => {33 page.$('input').then(element => {34 element.type('Hello');35 });36});37const { getPublicInstance } = require('playwright/lib/server/browserContext');38const { BrowserContext } = require('playwright/lib/server/browserContext');39const { Page } = require('playwright/lib/server/page');40const { ElementHandle } = require('playwright/lib/server/dom');41const context = getPublicInstance(BrowserContext);
Using AI Code Generation
1const playwright = require('playwright');2const { getPublicInstance } = require('playwright/lib/server/frames');3(async () => {4 const browser = await playwright.chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const publicPage = getPublicInstance(page);8 const title = await publicPage.title();9 console.log(title);10 await browser.close();11})();12const playwright = require('playwright');13const { getPublicInstance } = require('playwright/lib/server/frames');14(async () => {15 const browser = await playwright.chromium.launch();16 const context = await browser.newContext();17 const page = await context.newPage();18 const publicPage = getPublicInstance(page);19 const title = await publicPage.title();20 console.log(title);21 await browser.close();22})();
Using AI Code Generation
1const playwright = require('playwright');2const { getPublicInstance } = require('playwright/lib/server/browserType');3const browser = getPublicInstance(playwright.chromium);4console.log(browser);5Browser {6 _browserType: BrowserType {
Using AI Code Generation
1const { getPublicInstance } = require('playwright/lib/server/page');2const page = await context.newPage();3const publicPage = getPublicInstance(page);4publicPage.on('request', request => {5 console.log('Request: ' + request.url());6});7publicPage.on('response', response => {8 console.log('Response: ' + response.url());9});10await publicPage.waitForTimeout(1000);11const { getPublicInstance } = require('playwright/lib/server/browserContext');12const context = await browser.newContext();13const publicContext = getPublicInstance(context);14publicContext.on('request', request => {15 console.log('Request: ' + request.url());16});17publicContext.on('response', response => {18 console.log('Response: ' + response.url());19});20const page = await publicContext.newPage();21await page.waitForTimeout(1000);22const { getPublicInstance } = require('playwright/lib/server/browser');23const browser = await chromium.launch();24const publicBrowser = getPublicInstance(browser);25publicBrowser.on('request', request => {26 console.log('Request: ' + request.url());27});28publicBrowser.on('response', response => {29 console.log('Response: ' + response.url());30});31const context = await publicBrowser.newContext();32const page = await context.newPage();33await page.waitForTimeout(1000);34const { getPublicInstance } = require('playwright/lib/server/frame');35const browser = await chromium.launch();36const context = await browser.newContext();37const page = await context.newPage();38const frame = page.mainFrame();39const publicFrame = getPublicInstance(frame);40publicFrame.on('request', request => {41 console.log('Request: ' + request.url());42});43publicFrame.on('response', response => {44 console.log('Response: ' + response.url());45});
Jest + Playwright - Test callbacks of event-based DOM library
firefox browser does not start in playwright
Is it possible to get the selector from a locator object in playwright?
How to run a list of test suites in a single file concurrently in jest?
Running Playwright in Azure Function
firefox browser does not start in playwright
This question is quite close to a "need more focus" question. But let's try to give it some focus:
Does Playwright has access to the cPicker object on the page? Does it has access to the window object?
Yes, you can access both cPicker and the window object inside an evaluate call.
Should I trigger the events from the HTML file itself, and in the callbacks, print in the DOM the result, in some dummy-element, and then infer from that dummy element text that the callbacks fired?
Exactly, or you can assign values to a javascript variable:
const cPicker = new ColorPicker({
onClickOutside(e){
},
onInput(color){
window['color'] = color;
},
onChange(color){
window['result'] = color;
}
})
And then
it('Should call all callbacks with correct arguments', async() => {
await page.goto(`http://localhost:5000/tests/visual/basic.html`, {waitUntil:'load'})
// Wait until the next frame
await page.evaluate(() => new Promise(requestAnimationFrame))
// Act
// Assert
const result = await page.evaluate(() => window['color']);
// Check the value
})
Check out the latest blogs from LambdaTest on this topic:
Native apps are developed specifically for one platform. Hence they are fast and deliver superior performance. They can be downloaded from various app stores and are not accessible through browsers.
One of the essential parts when performing automated UI testing, whether using Selenium or another framework, is identifying the correct web elements the tests will interact with. However, if the web elements are not located correctly, you might get NoSuchElementException in Selenium. This would cause a false negative result because we won’t get to the actual functionality check. Instead, our test will fail simply because it failed to interact with the correct element.
Smartphones have changed the way humans interact with technology. Be it travel, fitness, lifestyle, video games, or even services, it’s all just a few touches away (quite literally so). We only need to look at the growing throngs of smartphone or tablet users vs. desktop users to grasp this reality.
As part of one of my consulting efforts, I worked with a mid-sized company that was looking to move toward a more agile manner of developing software. As with any shift in work style, there is some bewilderment and, for some, considerable anxiety. People are being challenged to leave their comfort zones and embrace a continuously changing, dynamic working environment. And, dare I say it, testing may be the most ‘disturbed’ of the software roles in agile development.
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!