How to use effect method in storybook-root

Best JavaScript code snippet using storybook-root

effects.js

Source:effects.js Github

copy

Full Screen

...121 delay: 0.0122 }, arguments[2] || {});123 var masterDelay = options.delay;124 $A(elements).each( function(element, index) {125 new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay }));126 });127 },128 PAIRS: {129 'slide': ['SlideDown','SlideUp'],130 'blind': ['BlindDown','BlindUp'],131 'appear': ['Appear','Fade']132 },133 toggle: function(element, effect) {134 element = $(element);135 effect = (effect || 'appear').toLowerCase();136 var options = Object.extend({137 queue: { position:'end', scope:(element.id || 'global'), limit: 1 }138 }, arguments[2] || {});139 Effect[element.visible() ? ...

Full Screen

Full Screen

system_effect.js

Source:system_effect.js Github

copy

Full Screen

1/**2 * Created by exodus4d on 06.07.2015.3 * static system effects4 */5define([], () => {6 'use strict';7 /**8 * get system effect multiplier9 * @param areaId10 * @returns {number}11 */12 let getMultiplierByAreaId = areaId => {13 let multiply = 0;14 switch(areaId){15 case 1:16 case 2:17 case 3:18 case 4:19 case 5:20 case 6:21 multiply = areaId; // C1-C6 holes22 break;23 case 13:24 multiply = 6; // Shattered frigate holes25 break;26 case 14:27 case 15:28 case 16:29 case 17:30 case 18:31 multiply = 2; // Drifter space32 break;33 }34 return multiply;35 };36 let magnetar = {37 1: [38 {39 effect: 'Damage',40 value: '+30%'41 }, {42 effect: 'Missile exp. radius',43 value: '+15%'44 }, {45 effect: 'Drone tracking',46 value: '-15%'47 }, {48 effect: 'Targeting range',49 value: '-15%'50 }, {51 effect: 'Tracking speed',52 value: '-15%'53 }, {54 effect: 'Target Painter strength',55 value: '-15%'56 }57 ],58 2: [59 {60 effect: 'Damage',61 value: '+44%'62 }, {63 effect: 'Missile exp. radius',64 value: '+22%'65 }, {66 effect: 'Drone tracking',67 value: '-22%'68 }, {69 effect: 'Targeting range',70 value: '-22%'71 }, {72 effect: 'Tracking speed',73 value: '-22%'74 }, {75 effect: 'Target Painter strength',76 value: '-22%'77 }78 ],79 3: [80 {81 effect: 'Damage',82 value: '+58%'83 }, {84 effect: 'Missile exp. radius',85 value: '+29%'86 }, {87 effect: 'Drone tracking',88 value: '-29%'89 }, {90 effect: 'Targeting range',91 value: '-29%'92 }, {93 effect: 'Tracking speed',94 value: '-29%'95 }, {96 effect: 'Target Painter strength',97 value: '-29%'98 }99 ],100 4: [101 {102 effect: 'Damage',103 value: '+72%'104 }, {105 effect: 'Missile exp. radius',106 value: '+36%'107 }, {108 effect: 'Drone tracking',109 value: '-36%'110 }, {111 effect: 'Targeting range',112 value: '-36%'113 }, {114 effect: 'Tracking speed',115 value: '-36%'116 }, {117 effect: 'Target Painter strength',118 value: '-36%'119 }120 ],121 5: [122 {123 effect: 'Damage',124 value: '+86%'125 }, {126 effect: 'Missile exp. radius',127 value: '+43%'128 }, {129 effect: 'Drone tracking',130 value: '-43%'131 }, {132 effect: 'Targeting range',133 value: '-43%'134 }, {135 effect: 'Tracking speed',136 value: '-43%'137 }, {138 effect: 'Target Painter strength',139 value: '-43%'140 }141 ],142 6: [143 {144 effect: 'Damage',145 value: '+100%'146 }, {147 effect: 'Missile exp. radius',148 value: '+50%'149 }, {150 effect: 'Drone tracking',151 value: '-50%'152 }, {153 effect: 'Targeting range',154 value: '-50%'155 }, {156 effect: 'Tracking speed',157 value: '-50%'158 }, {159 effect: 'Target Painter strength',160 value: '-50%'161 }162 ]163 };164 let redGiant = {165 1: [166 {167 effect: 'Heat damage',168 value: '+15%'169 }, {170 effect: 'Overload bonus',171 value: '+30%'172 }, {173 effect: 'Smart Bomb range',174 value: '+30%'175 }, {176 effect: 'Smart Bomb damage',177 value: '+30%'178 }, {179 effect: 'Bomb damage',180 value: '+30%'181 }182 ],183 2: [184 {185 effect: 'Heat damage',186 value: '+22%'187 }, {188 effect: 'Overload bonus',189 value: '+44%'190 }, {191 effect: 'Smart Bomb range',192 value: '+44%'193 }, {194 effect: 'Smart Bomb damage',195 value: '+44%'196 }, {197 effect: 'Bomb damage',198 value: '+44%'199 }200 ],201 3: [202 {203 effect: 'Heat damage',204 value: '+29%'205 }, {206 effect: 'Overload bonus',207 value: '+58%'208 }, {209 effect: 'Smart Bomb range',210 value: '+58%'211 }, {212 effect: 'Smart Bomb damage',213 value: '+58%'214 }, {215 effect: 'Bomb damage',216 value: '+58%'217 }218 ],219 4: [220 {221 effect: 'Heat damage',222 value: '+36%'223 }, {224 effect: 'Overload bonus',225 value: '+72%'226 }, {227 effect: 'Smart Bomb range',228 value: '+72%'229 }, {230 effect: 'Smart Bomb damage',231 value: '+72%'232 }, {233 effect: 'Bomb damage',234 value: '+72%'235 }236 ],237 5: [238 {239 effect: 'Heat damage',240 value: '+43%'241 }, {242 effect: 'Overload bonus',243 value: '+86%'244 }, {245 effect: 'Smart Bomb range',246 value: '+86%'247 }, {248 effect: 'Smart Bomb damage',249 value: '+86%'250 }, {251 effect: 'Bomb damage',252 value: '+86%'253 }254 ],255 6: [256 {257 effect: 'Heat damage',258 value: '+50%'259 }, {260 effect: 'Overload bonus',261 value: '+100%'262 }, {263 effect: 'Smart Bomb range',264 value: '+100%'265 }, {266 effect: 'Smart Bomb damage',267 value: '+100%'268 }, {269 effect: 'Bomb damage',270 value: '+100%'271 }272 ]273 };274 let pulsar = {275 1: [276 {277 effect: 'Shield HP',278 value: '+30%'279 }, {280 effect: 'Armor resist',281 value: '-15%'282 }, {283 effect: 'Capacitor recharge',284 value: '-15%'285 }, {286 effect: 'Signature',287 value: '+30%'288 }, {289 effect: 'NOS/Neut drain',290 value: '+30%'291 }292 ],293 2: [294 {295 effect: 'Shield HP',296 value: '+44%'297 }, {298 effect: 'Armor resist',299 value: '-22%'300 }, {301 effect: 'Capacitor recharge',302 value: '-22%'303 }, {304 effect: 'Signature',305 value: '+44%'306 }, {307 effect: 'NOS/Neut drain',308 value: '+44%'309 }310 ],311 3: [312 {313 effect: 'Shield HP',314 value: '+58%'315 }, {316 effect: 'Armor resist',317 value: '-29%'318 }, {319 effect: 'Capacitor recharge',320 value: '-29%'321 }, {322 effect: 'Signature',323 value: '+58%'324 }, {325 effect: 'NOS/Neut drain',326 value: '+58%'327 }328 ],329 4: [330 {331 effect: 'Shield HP',332 value: '+72%'333 }, {334 effect: 'Armor resist',335 value: '-36%'336 }, {337 effect: 'Capacitor recharge',338 value: '-36%'339 }, {340 effect: 'Signature',341 value: '+72%'342 }, {343 effect: 'NOS/Neut drain',344 value: '+72%'345 }346 ],347 5: [348 {349 effect: 'Shield HP',350 value: '+86%'351 }, {352 effect: 'Armor resist',353 value: '-43%'354 }, {355 effect: 'Capacitor recharge',356 value: '-43%'357 }, {358 effect: 'Signature',359 value: '+86%'360 }, {361 effect: 'NOS/Neut drain',362 value: '+86%'363 }364 ],365 6: [366 {367 effect: 'Shield HP',368 value: '+100%'369 }, {370 effect: 'Armor resist',371 value: '-50%'372 }, {373 effect: 'Capacitor recharge',374 value: '-50%'375 }, {376 effect: 'Signature',377 value: '+100%'378 }, {379 effect: 'NOS/Neut drain',380 value: '+100%'381 }382 ]383 };384 let wolfRayet = {385 1: [386 {387 effect: 'Armor HP',388 value: '+30%'389 }, {390 effect: 'Shield resist',391 value: '-15%'392 }, {393 effect: 'Small Weapon damage',394 value: '+60%'395 }, {396 effect: 'Signature size',397 value: '-15%'398 }399 ],400 2: [401 {402 effect: 'Armor HP',403 value: '+44%'404 }, {405 effect: 'Shield resist',406 value: '-22%'407 }, {408 effect: 'Small Weapon damage',409 value: '+88%'410 }, {411 effect: 'Signature size',412 value: '-22%'413 }414 ],415 3: [416 {417 effect: 'Armor HP',418 value: '+58%'419 }, {420 effect: 'Shield resist',421 value: '-29%'422 }, {423 effect: 'Small Weapon damage',424 value: '+116%'425 }, {426 effect: 'Signature size',427 value: '-29%'428 }429 ],430 4: [431 {432 effect: 'Armor HP',433 value: '+72%'434 }, {435 effect: 'Shield resist',436 value: '-36%'437 }, {438 effect: 'Small Weapon damage',439 value: '+144%'440 }, {441 effect: 'Signature size',442 value: '-36%'443 }444 ],445 5: [446 {447 effect: 'Armor HP',448 value: '+86%'449 }, {450 effect: 'Shield resist',451 value: '-43%'452 }, {453 effect: 'Small Weapon damage',454 value: '+172%'455 }, {456 effect: 'Signature size',457 value: '-43%'458 }459 ],460 6: [461 {462 effect: 'Armor HP',463 value: '+100%'464 }, {465 effect: 'Shield resist',466 value: '-50%'467 }, {468 effect: 'Small Weapon damage',469 value: '+200%'470 }, {471 effect: 'Signature size',472 value: '-50%'473 }474 ]475 };476 let cataclysmic = {477 1: [478 {479 effect: 'Local armor repair amount',480 value: '-15%'481 }, {482 effect: 'Local shield boost amount',483 value: '-15%'484 }, {485 effect: 'Shield transfer amount',486 value: '+30%'487 }, {488 effect: 'Remote repair amount',489 value: '+30%'490 }, {491 effect: 'Capacitor capacity',492 value: '+30%'493 }, {494 effect: 'Capacitor recharge time',495 value: '+15%'496 }, {497 effect: 'Remote Capacitor Transmitter amount',498 value: '-15%'499 }500 ],501 2: [502 {503 effect: 'Local armor repair amount',504 value: '-22%'505 }, {506 effect: 'Local shield boost amount',507 value: '-22%'508 }, {509 effect: 'Shield transfer amount',510 value: '+44%'511 }, {512 effect: 'Remote repair amount',513 value: '+44%'514 }, {515 effect: 'Capacitor capacity',516 value: '+44%'517 }, {518 effect: 'Capacitor recharge time',519 value: '+22%'520 }, {521 effect: 'Remote Capacitor Transmitter amount',522 value: '-22%'523 }524 ],525 3: [526 {527 effect: 'Local armor repair amount',528 value: '-29%'529 }, {530 effect: 'Local shield boost amount',531 value: '-29%'532 }, {533 effect: 'Shield transfer amount',534 value: '+58%'535 }, {536 effect: 'Remote repair amount',537 value: '+58%'538 }, {539 effect: 'Capacitor capacity',540 value: '+58%'541 }, {542 effect: 'Capacitor recharge time',543 value: '+29%'544 }, {545 effect: 'Remote Capacitor Transmitter amount',546 value: '-29%'547 }548 ],549 4: [550 {551 effect: 'Local armor repair amount',552 value: '-36%'553 }, {554 effect: 'Local shield boost amount',555 value: '-36%'556 }, {557 effect: 'Shield transfer amount',558 value: '+72%'559 }, {560 effect: 'Remote repair amount',561 value: '+72%'562 }, {563 effect: 'Capacitor capacity',564 value: '+72%'565 }, {566 effect: 'Capacitor recharge time',567 value: '+36%'568 }, {569 effect: 'Remote Capacitor Transmitter amount',570 value: '-36%'571 }572 ],573 5: [574 {575 effect: 'Local armor repair amount',576 value: '-43%'577 }, {578 effect: 'Local shield boost amount',579 value: '-43%'580 }, {581 effect: 'Shield transfer amount',582 value: '+86%'583 }, {584 effect: 'Remote repair amount',585 value: '+86%'586 }, {587 effect: 'Capacitor capacity',588 value: '+86%'589 }, {590 effect: 'Capacitor recharge time',591 value: '+43%'592 }, {593 effect: 'Remote Capacitor Transmitter amount',594 value: '-43%'595 }596 ],597 6: [598 {599 effect: 'Local armor repair amount',600 value: '-50%'601 }, {602 effect: 'Local shield boost amount',603 value: '-50%'604 }, {605 effect: 'Shield transfer amount',606 value: '+100%'607 }, {608 effect: 'Remote repair amount',609 value: '+100%'610 }, {611 effect: 'Capacitor capacity',612 value: '+100%'613 }, {614 effect: 'Capacitor recharge time',615 value: '+50%'616 }, {617 effect: 'Remote Capacitor Transmitter amount',618 value: '-50%'619 }620 ]621 };622 let blackHole = {623 1: [624 {625 effect: 'Missile velocity',626 value: '+15%'627 }, {628 effect: 'Missile exp. velocity',629 value: '+30%'630 }, {631 effect: 'Ship velocity',632 value: '+30%'633 }, {634 effect: 'Stasis Webifier strength',635 value: '-15%'636 }, {637 effect: 'Inertia',638 value: '+15%'639 }, {640 effect: 'Targeting range',641 value: '+30%'642 }643 ],644 2: [645 {646 effect: 'Missile velocity',647 value: '+22%'648 }, {649 effect: 'Missile exp. velocity',650 value: '+44%'651 }, {652 effect: 'Ship velocity',653 value: '+44%'654 }, {655 effect: 'Stasis Webifier strength',656 value: '-22%'657 }, {658 effect: 'Inertia',659 value: '+22%'660 }, {661 effect: 'Targeting range',662 value: '+44%'663 }664 ],665 3: [666 {667 effect: 'Missile velocity',668 value: '+29%'669 }, {670 effect: 'Missile exp. velocity',671 value: '+58%'672 }, {673 effect: 'Ship velocity',674 value: '+58%'675 }, {676 effect: 'Stasis Webifier strength',677 value: '-29%'678 }, {679 effect: 'Inertia',680 value: '+29%'681 }, {682 effect: 'Targeting range',683 value: '+58%'684 }685 ],686 4: [687 {688 effect: 'Missile velocity',689 value: '+36%'690 }, {691 effect: 'Missile exp. velocity',692 value: '+72%'693 }, {694 effect: 'Ship velocity',695 value: '+72%'696 }, {697 effect: 'Stasis Webifier strength',698 value: '-36%'699 }, {700 effect: 'Inertia',701 value: '+36%'702 }, {703 effect: 'Targeting range',704 value: '+72%'705 }706 ],707 5: [708 {709 effect: 'Missile velocity',710 value: '+43%'711 }, {712 effect: 'Missile exp. velocity',713 value: '+86%'714 }, {715 effect: 'Ship velocity',716 value: '+86%'717 }, {718 effect: 'Stasis Webifier strength',719 value: '-43%'720 }, {721 effect: 'Inertia',722 value: '+43%'723 }, {724 effect: 'Targeting range',725 value: '+86%'726 }727 ],728 6: [729 {730 effect: 'Missile velocity',731 value: '+50%'732 }, {733 effect: 'Missile exp. velocity',734 value: '+100%'735 }, {736 effect: 'Ship velocity',737 value: '+100%'738 }, {739 effect: 'Stasis Webifier strength',740 value: '-50%'741 }, {742 effect: 'Inertia',743 value: '+50%'744 }, {745 effect: 'Targeting range',746 value: '+100%'747 }748 ]749 };750 // system effects751 return {752 getMultiplierByAreaId: getMultiplierByAreaId,753 wh: {754 magnetar: {755 1: magnetar[getMultiplierByAreaId(1)],756 2: magnetar[getMultiplierByAreaId(2)],757 3: magnetar[getMultiplierByAreaId(3)],758 4: magnetar[getMultiplierByAreaId(4)],759 5: magnetar[getMultiplierByAreaId(5)],760 6: magnetar[getMultiplierByAreaId(6)],761 16: magnetar[getMultiplierByAreaId(16)]762 },763 redGiant: {764 1: redGiant[getMultiplierByAreaId(1)],765 2: redGiant[getMultiplierByAreaId(2)],766 3: redGiant[getMultiplierByAreaId(3)],767 4: redGiant[getMultiplierByAreaId(4)],768 5: redGiant[getMultiplierByAreaId(5)],769 6: redGiant[getMultiplierByAreaId(6)],770 14: redGiant[getMultiplierByAreaId(14)]771 },772 pulsar: {773 1: pulsar[getMultiplierByAreaId(1)],774 2: pulsar[getMultiplierByAreaId(2)],775 3: pulsar[getMultiplierByAreaId(3)],776 4: pulsar[getMultiplierByAreaId(4)],777 5: pulsar[getMultiplierByAreaId(5)],778 6: pulsar[getMultiplierByAreaId(6)],779 17: pulsar[getMultiplierByAreaId(17)]780 },781 wolfRayet: {782 1: wolfRayet[getMultiplierByAreaId(1)],783 2: wolfRayet[getMultiplierByAreaId(2)],784 3: wolfRayet[getMultiplierByAreaId(3)],785 4: wolfRayet[getMultiplierByAreaId(4)],786 5: wolfRayet[getMultiplierByAreaId(5)],787 6: wolfRayet[getMultiplierByAreaId(6)],788 13: wolfRayet[getMultiplierByAreaId(13)],789 18: wolfRayet[getMultiplierByAreaId(18)]790 },791 cataclysmic: {792 1: cataclysmic[getMultiplierByAreaId(1)],793 2: cataclysmic[getMultiplierByAreaId(2)],794 3: cataclysmic[getMultiplierByAreaId(3)],795 4: cataclysmic[getMultiplierByAreaId(4)],796 5: cataclysmic[getMultiplierByAreaId(5)],797 6: cataclysmic[getMultiplierByAreaId(6)],798 15: cataclysmic[getMultiplierByAreaId(15)]799 },800 blackHole: {801 1: blackHole[getMultiplierByAreaId(1)],802 2: blackHole[getMultiplierByAreaId(2)],803 3: blackHole[getMultiplierByAreaId(3)],804 4: blackHole[getMultiplierByAreaId(4)],805 5: blackHole[getMultiplierByAreaId(5)],806 6: blackHole[getMultiplierByAreaId(6)]807 }808 }809 };...

Full Screen

Full Screen

ecEffect.js

Source:ecEffect.js Github

copy

Full Screen

1/**2 * echarts图表特效基类3 *4 * @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。5 * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)6 *7 */8define(function (require) {9 var ecData = require('../util/ecData');10 11 var CircleShape = require('zrender/shape/Circle');12 var ImageShape = require('zrender/shape/Image');13 var curveTool = require('zrender/tool/curve');14 var IconShape = require('../util/shape/Icon');15 var SymbolShape = require('../util/shape/Symbol');16 var ShapeBundle = require('zrender/shape/ShapeBundle');17 var Polyline = require('zrender/shape/Polyline');18 var vec2 = require('zrender/tool/vector');19 var canvasSupported = require('zrender/tool/env').canvasSupported;20 21 function point(zr, effectList, shape, zlevel) {22 var effect = shape.effect;23 var color = effect.color || shape.style.strokeColor || shape.style.color;24 var shadowColor = effect.shadowColor || color;25 var size = effect.scaleSize;26 var distance = effect.bounceDistance;27 var shadowBlur = typeof effect.shadowBlur != 'undefined'28 ? effect.shadowBlur : size;29 var effectShape;30 if (shape.type !== 'image') {31 effectShape = new IconShape({32 zlevel : zlevel,33 style : {34 brushType : 'stroke',35 iconType : shape.style.iconType != 'droplet'36 ? shape.style.iconType37 : 'circle',38 x : shadowBlur + 1, // 线宽39 y : shadowBlur + 1,40 n : shape.style.n,41 width : shape.style._width * size,42 height : shape.style._height * size,43 lineWidth : 1,44 strokeColor : color,45 shadowColor : shadowColor,46 shadowBlur : shadowBlur47 },48 draggable : false,49 hoverable : false50 });51 if (shape.style.iconType == 'pin') {52 effectShape.style.y += effectShape.style.height / 2 * 1.5;53 }54 if (canvasSupported) { // 提高性能,换成image55 effectShape.style.image = zr.shapeToImage(56 effectShape, 57 effectShape.style.width + shadowBlur * 2 + 2, 58 effectShape.style.height + shadowBlur * 2 + 259 ).style.image;60 61 effectShape = new ImageShape({62 zlevel : effectShape.zlevel,63 style : effectShape.style,64 draggable : false,65 hoverable : false66 });67 }68 }69 else {70 effectShape = new ImageShape({71 zlevel : zlevel,72 style : shape.style,73 draggable : false,74 hoverable : false75 });76 }77 78 ecData.clone(shape, effectShape);79 80 // 改变坐标,不能移到前面81 effectShape.position = shape.position;82 effectList.push(effectShape);83 zr.addShape(effectShape);84 85 var devicePixelRatio = shape.type !== 'image' ? (window.devicePixelRatio || 1) : 1;86 var offset = (effectShape.style.width / devicePixelRatio - shape.style._width) / 2;87 effectShape.style.x = shape.style._x - offset;88 effectShape.style.y = shape.style._y - offset;89 if (shape.style.iconType == 'pin') {90 effectShape.style.y -= shape.style.height / 2 * 1.5;91 }92 var duration = (effect.period + Math.random() * 10) * 100;93 94 zr.modShape(95 shape.id, 96 { invisible : true}97 );98 99 var centerX = effectShape.style.x + (effectShape.style.width) / 2 / devicePixelRatio;100 var centerY = effectShape.style.y + (effectShape.style.height) / 2 / devicePixelRatio;101 if (effect.type === 'scale') {102 // 放大效果103 zr.modShape(104 effectShape.id, 105 {106 scale : [0.1, 0.1, centerX, centerY]107 }108 );109 110 zr.animate(effectShape.id, '', effect.loop)111 .when(112 duration,113 {114 scale : [1, 1, centerX, centerY]115 }116 )117 .done(function() {118 shape.effect.show = false;119 zr.delShape(effectShape.id);120 })121 .start();122 }123 else {124 zr.animate(effectShape.id, 'style', effect.loop)125 .when(126 duration,127 {128 y : effectShape.style.y - distance129 }130 )131 .when(132 duration * 2,133 {134 y : effectShape.style.y135 }136 )137 .done(function() {138 shape.effect.show = false;139 zr.delShape(effectShape.id);140 })141 .start();142 }143 144 }145 146 function largePoint(zr, effectList, shape, zlevel) {147 var effect = shape.effect;148 var color = effect.color || shape.style.strokeColor || shape.style.color;149 var size = effect.scaleSize;150 var shadowColor = effect.shadowColor || color;151 var shadowBlur = typeof effect.shadowBlur != 'undefined'152 ? effect.shadowBlur : (size * 2);153 var devicePixelRatio = window.devicePixelRatio || 1;154 var effectShape = new SymbolShape({155 zlevel : zlevel,156 position : shape.position,157 scale : shape.scale,158 style : {159 pointList : shape.style.pointList,160 iconType : shape.style.iconType,161 color : color,162 strokeColor : color,163 shadowColor : shadowColor,164 shadowBlur : shadowBlur * devicePixelRatio,165 random : true,166 brushType: 'fill',167 lineWidth:1,168 size : shape.style.size169 },170 draggable : false,171 hoverable : false172 });173 174 effectList.push(effectShape);175 zr.addShape(effectShape);176 zr.modShape(177 shape.id, 178 { invisible : true}179 );180 181 var duration = Math.round(effect.period * 100);182 var clip1 = {};183 var clip2 = {};184 for (var i = 0; i < 20; i++) {185 effectShape.style['randomMap' + i] = 0;186 clip1 = {};187 clip1['randomMap' + i] = 100;188 clip2 = {};189 clip2['randomMap' + i] = 0;190 effectShape.style['randomMap' + i] = Math.random() * 100;191 zr.animate(effectShape.id, 'style', true)192 .when(duration, clip1)193 .when(duration * 2, clip2)194 .when(duration * 3, clip1)195 .when(duration * 4, clip1)196 .delay(Math.random() * duration * i)197 //.delay(duration / 15 * (15 - i + 1))198 .start();199 200 }201 }202 203 function line(zr, effectList, shape, zlevel, isLarge) {204 var effect = shape.effect;205 var shapeStyle = shape.style;206 var color = effect.color || shapeStyle.strokeColor || shapeStyle.color;207 var shadowColor = effect.shadowColor || shapeStyle.strokeColor || color;208 var size = shapeStyle.lineWidth * effect.scaleSize;209 var shadowBlur = typeof effect.shadowBlur != 'undefined'210 ? effect.shadowBlur : size;211 var effectShape = new CircleShape({212 zlevel : zlevel,213 style : {214 x : shadowBlur,215 y : shadowBlur,216 r : size,217 color : color,218 shadowColor : shadowColor,219 shadowBlur : shadowBlur220 },221 hoverable : false222 });223 var offset = 0;224 if (canvasSupported && ! isLarge) { // 提高性能,换成image225 var zlevel = effectShape.zlevel;226 effectShape = zr.shapeToImage(227 effectShape,228 (size + shadowBlur) * 2,229 (size + shadowBlur) * 2230 );231 effectShape.zlevel = zlevel;232 effectShape.hoverable = false;233 offset = shadowBlur;234 }235 if (! isLarge) {236 ecData.clone(shape, effectShape);237 // 改变坐标, 不能移到前面238 effectShape.position = shape.position;239 effectList.push(effectShape);240 zr.addShape(effectShape);241 }242 var effectDone = function () {243 if (! isLarge) {244 shape.effect.show = false;245 zr.delShape(effectShape.id); 246 }247 effectShape.effectAnimator = null;248 };249 if (shape instanceof Polyline) {250 var distanceList = [0];251 var totalDist = 0;252 var pointList = shapeStyle.pointList;253 var controlPointList = shapeStyle.controlPointList;254 for (var i = 1; i < pointList.length; i++) {255 if (controlPointList) {256 var cp1 = controlPointList[(i - 1) * 2];257 var cp2 = controlPointList[(i - 1) * 2 + 1];258 totalDist += vec2.dist(pointList[i - 1], cp1)259 + vec2.dist(cp1, cp2)260 + vec2.dist(cp2, pointList[i]);261 }262 else {263 totalDist += vec2.dist(pointList[i - 1], pointList[i]);264 }265 distanceList.push(totalDist);266 }267 var obj = { p: 0 };268 var animator = zr.animation.animate(obj, { loop: effect.loop });269 for (var i = 0; i < distanceList.length; i++) {270 animator.when(distanceList[i] * effect.period, { p: i });271 }272 animator.during(function () {273 var i = Math.floor(obj.p);274 var x, y;275 if (i == pointList.length - 1) {276 x = pointList[i][0];277 y = pointList[i][1];278 }279 else {280 var t = obj.p - i;281 var p0 = pointList[i];282 var p1 = pointList[i + 1];283 if (controlPointList) {284 var cp1 = controlPointList[i * 2];285 var cp2 = controlPointList[i * 2 + 1];286 x = curveTool.cubicAt(287 p0[0], cp1[0], cp2[0], p1[0], t288 );289 y = curveTool.cubicAt(290 p0[1], cp1[1], cp2[1], p1[1], t291 );292 }293 else {294 x = (p1[0] - p0[0]) * t + p0[0];295 y = (p1[1] - p0[1]) * t + p0[1]; 296 }297 }298 effectShape.style.x = x;299 effectShape.style.y = y;300 if (! isLarge) {301 zr.modShape(effectShape);302 }303 })304 .done(effectDone)305 .start();306 animator.duration = totalDist * effect.period;307 effectShape.effectAnimator = animator;308 }309 else {310 var x0 = shapeStyle.xStart - offset;311 var y0 = shapeStyle.yStart - offset;312 var x2 = shapeStyle.xEnd - offset;313 var y2 = shapeStyle.yEnd - offset;314 effectShape.style.x = x0;315 effectShape.style.y = y0;316 var distance = (x2 - x0) * (x2 - x0) + (y2 - y0) * (y2 - y0);317 var duration = Math.round(Math.sqrt(Math.round(318 distance * effect.period * effect.period319 )));320 if (shape.style.curveness > 0) {321 var x1 = shapeStyle.cpX1 - offset;322 var y1 = shapeStyle.cpY1 - offset;323 effectShape.effectAnimator = zr.animation.animate(effectShape, { loop: effect.loop })324 .when(duration, { p: 1 })325 .during(function (target, t) {326 effectShape.style.x = curveTool.quadraticAt(327 x0, x1, x2, t328 );329 effectShape.style.y = curveTool.quadraticAt(330 y0, y1, y2, t331 );332 if (! isLarge) {333 zr.modShape(effectShape);334 }335 })336 .done(effectDone)337 .start();338 }339 else {340 // 不用 zr.animate,因为在用 ShapeBundle 的时候单个 effectShape 不会341 // 被加到 zrender 中342 effectShape.effectAnimator = zr.animation.animate(effectShape.style, { loop: effect.loop })343 .when(duration, {344 x: x2,345 y: y2346 })347 .during(function () {348 if (! isLarge) {349 zr.modShape(effectShape);350 }351 })352 .done(effectDone)353 .start();354 }355 effectShape.effectAnimator.duration = duration;356 }357 return effectShape;358 }359 function largeLine(zr, effectList, shape, zlevel) {360 var effectShape = new ShapeBundle({361 style: {362 shapeList: []363 },364 zlevel: zlevel,365 hoverable: false366 });367 var shapeList = shape.style.shapeList;368 var effect = shape.effect;369 effectShape.position = shape.position;370 var maxDuration = 0;371 var subEffectAnimators = [];372 for (var i = 0; i < shapeList.length; i++) {373 shapeList[i].effect = effect;374 var subEffectShape = line(zr, null, shapeList[i], zlevel, true);375 var subEffectAnimator = subEffectShape.effectAnimator;376 effectShape.style.shapeList.push(subEffectShape);377 if (subEffectAnimator.duration > maxDuration) {378 maxDuration = subEffectAnimator.duration;379 }380 if (i === 0) {381 effectShape.style.color = subEffectShape.style.color;382 effectShape.style.shadowBlur = subEffectShape.style.shadowBlur;383 effectShape.style.shadowColor = subEffectShape.style.shadowColor;384 }385 subEffectAnimators.push(subEffectAnimator);386 }387 effectList.push(effectShape);388 zr.addShape(effectShape);389 var clearAllAnimators = function () {390 for (var i = 0; i < subEffectAnimators.length; i++) {391 subEffectAnimators[i].stop();392 }393 };394 if (maxDuration) {395 effectShape.__dummy = 0;396 // Proxy animator397 var animator = zr.animate(effectShape.id, '', effect.loop)398 .when(maxDuration, {399 __dummy: 1400 })401 .during(function () {402 zr.modShape(effectShape);403 })404 .done(function () {405 shape.effect.show = false;406 zr.delShape(effectShape.id);407 })408 .start();409 var oldStop = animator.stop;410 animator.stop = function () {411 clearAllAnimators();412 oldStop.call(this);413 };414 }415 }416 return {417 point : point,418 largePoint : largePoint,419 line : line,420 largeLine: largeLine421 };...

Full Screen

Full Screen

TextEffectsUtils.js

Source:TextEffectsUtils.js Github

copy

Full Screen

1/**2 * TextEffectsUtils3 * @Author Ace.c4 * @Time 2016-08-09 13:475 */6var TextEffectsUtils = (function () {7 function TextEffectsUtils() {8 }9 var d = __define,c=TextEffectsUtils,p=c.prototype;10 /**11 * 打字机特效12 * @param display 文本对象13 * @param content 文本内容14 * @param delay 打字间隔(单位:毫秒)15 */16 TextEffectsUtils.typewriter = function (display, content, delay) {17 if (content === void 0) { content = ""; }18 if (delay === void 0) { delay = 50; }19 var strArr = content.split("");20 for (var i = 0; i < strArr.length; i++) {21 egret.setTimeout(function () {22 display.appendText(strArr[Number(this)]);23 }, i, delay * i);24 }25 };26 /**27 * 数字滚动特效28 * @param display 文本对象29 * @param target 目标数字30 * @param delay 打字间隔(单位:毫秒)31 */32 TextEffectsUtils.numberRolling = function (display, target, delay) {33 if (delay === void 0) { delay = 2000; }34 this.rollingStart = Number(display.text);35 function onChange() {36 display.text = Math.round(this.rollingStart).toString();37 }38 egret.Tween.get(this, { onChange: onChange, onChangeObj: this }).to({ rollingStart: target }, delay);39 };40 /**41 * 提示特效42 * @param content 提示内容43 * @param type 类型 1:从下到上弹出 2:从左至右弹出 3:从右至左弹出 4:从中间弹出渐渐消失 5:从大变小 等等44 * @param isWarning 是否是警告,警告是红色45 */46 TextEffectsUtils.showTips = function (content, type, isWarning) {47 if (content === void 0) { content = ""; }48 if (type === void 0) { type = 1; }49 if (isWarning === void 0) { isWarning = false; }50 switch (type) {51 case 1:52 this.showTipsDownToUp(content, isWarning);53 break;54 case 2:55 this.showTipsLeftOrRight(content, isWarning, true);56 break;57 case 3:58 this.showTipsLeftOrRight(content, isWarning, false);59 break;60 case 4:61 this.showTipsFromCenter(content, isWarning);62 break;63 case 5:64 this.showTipsBigToSmall(content, isWarning);65 break;66 default:67 break;68 }69 };70 /**71 * 从下到上弹出72 * @param str73 * @param isWarning74 */75 TextEffectsUtils.showTipsDownToUp = function (str, isWarning) {76 if (str === void 0) { str = ""; }77 if (isWarning === void 0) { isWarning = false; }78 var effectTips = new egret.TextField();79 effectTips.size = 24;80 effectTips.y = H5Core.stageHeight / 2;81 if (isWarning) {82 effectTips.textColor = ColorType.red;83 }84 else {85 effectTips.textColor = ColorType.green;86 }87 effectTips.alpha = 0;88 effectTips.text = str;89 effectTips.strokeColor = 0x000000;90 effectTips.x = H5Core.stageWidth / 2 - effectTips.width / 2;91 effectTips.stroke = 2;92 effectTips.bold = true;93 effectTips.textAlign = egret.HorizontalAlign.CENTER;94 if (!H5Core.stage.contains(effectTips)) {95 H5Core.stage.addChild(effectTips);96 }97 var onComplete2 = function () {98 if (H5Core.stage.contains(effectTips)) {99 H5Core.stage.removeChild(effectTips);100 effectTips = null;101 }102 };103 var onComplete1 = function () {104 egret.Tween.get(effectTips).to({ alpha: 0 }, 500).call(onComplete2, this);105 };106 effectTips.visible = true;107 egret.Tween.get(effectTips).to({108 y: effectTips.y - 120,109 alpha: 1110 }, 800, egret.Ease.backOut).call(onComplete1, this);111 };112 /**113 * 从左至右 或者 从右至左114 * @param str115 * @param isWarning116 * @param isFromeLeft117 */118 TextEffectsUtils.showTipsLeftOrRight = function (str, isWarning, isFromeLeft) {119 if (str === void 0) { str = ""; }120 if (isWarning === void 0) { isWarning = false; }121 if (isFromeLeft === void 0) { isFromeLeft = true; }122 var effectTips = new egret.TextField();123 effectTips.size = 24;124 effectTips.y = H5Core.stageHeight / 2;125 if (isWarning) {126 effectTips.textColor = ColorType.red;127 }128 else {129 effectTips.textColor = ColorType.green;130 }131 effectTips.alpha = 0;132 effectTips.text = str;133 effectTips.strokeColor = 0x000000;134 if (isFromeLeft) {135 effectTips.x = -effectTips.width;136 }137 else {138 effectTips.x = H5Core.stageWidth;139 }140 effectTips.stroke = 2;141 effectTips.bold = true;142 effectTips.textAlign = egret.HorizontalAlign.CENTER;143 if (!H5Core.stage.contains(effectTips)) {144 H5Core.stage.addChild(effectTips);145 }146 if (isFromeLeft) {147 egret.Tween.get(effectTips).to({148 x: H5Core.stageWidth / 2 - effectTips.width / 2 - 50,149 alpha: 1150 }, 300, egret.Ease.sineInOut);151 }152 else {153 egret.Tween.get(effectTips).to({154 x: H5Core.stageWidth / 2 - effectTips.width / 2 + 50,155 alpha: 1156 }, 300, egret.Ease.sineInOut);157 }158 egret.setTimeout(function () {159 if (isFromeLeft) {160 egret.Tween.get(effectTips).to({ x: effectTips.x + 100 }, 500);161 }162 else {163 egret.Tween.get(effectTips).to({ x: effectTips.x - 100 }, 500);164 }165 }, this, 300);166 egret.setTimeout(function () {167 if (isFromeLeft) {168 egret.Tween.get(effectTips).to({ x: H5Core.stageWidth }, 300, egret.Ease.sineIn);169 }170 else {171 egret.Tween.get(effectTips).to({ x: -effectTips.width }, 300, egret.Ease.sineIn);172 }173 }, this, 800);174 egret.setTimeout(function () {175 if (H5Core.stage.contains(effectTips)) {176 H5Core.stage.removeChild(effectTips);177 effectTips = null;178 }179 }, this, 1100);180 };181 /**182 * 从里到外183 * @param str184 * @param isWarning185 */186 TextEffectsUtils.showTipsFromCenter = function (str, isWarning) {187 if (str === void 0) { str = ""; }188 if (isWarning === void 0) { isWarning = false; }189 var effectTips = new egret.TextField();190 effectTips.size = 24;191 effectTips.y = H5Core.stageHeight / 2;192 if (isWarning) {193 effectTips.textColor = ColorType.red;194 }195 else {196 effectTips.textColor = ColorType.green;197 }198 effectTips.alpha = 0;199 effectTips.text = str;200 effectTips.strokeColor = 0x000000;201 effectTips.x = H5Core.stageWidth / 2;202 effectTips.stroke = 2;203 effectTips.bold = true;204 effectTips.textAlign = egret.HorizontalAlign.CENTER;205 effectTips.anchorOffsetX = effectTips.width >> 1;206 effectTips.anchorOffsetY = effectTips.height >> 1;207 effectTips.scaleX = 0;208 effectTips.scaleY = 0;209 if (!H5Core.stage.contains(effectTips)) {210 H5Core.stage.addChild(effectTips);211 }212 var onComplete2 = function () {213 if (H5Core.stage.contains(effectTips)) {214 H5Core.stage.removeChild(effectTips);215 effectTips = null;216 }217 };218 egret.Tween.get(effectTips).to({ scaleX: 1, scaleY: 1, alpha: 1 }, 200);219 egret.setTimeout(function () {220 egret.Tween.get(effectTips).to({ alpha: 0 }, 500).call(onComplete2, this);221 }, this, 1000);222 };223 /**224 * 从外到里225 * @param str226 * @param isWarning227 */228 TextEffectsUtils.showTipsBigToSmall = function (str, isWarning) {229 if (str === void 0) { str = ""; }230 if (isWarning === void 0) { isWarning = false; }231 var effectTips = new egret.TextField();232 effectTips.size = 24;233 effectTips.y = H5Core.stageHeight / 2;234 if (isWarning) {235 effectTips.textColor = ColorType.red;236 }237 else {238 effectTips.textColor = ColorType.green;239 }240 effectTips.alpha = 0;241 effectTips.text = str;242 effectTips.strokeColor = 0x000000;243 effectTips.x = H5Core.stageWidth / 2;244 effectTips.stroke = 2;245 effectTips.bold = true;246 effectTips.textAlign = egret.HorizontalAlign.CENTER;247 effectTips.anchorOffsetX = effectTips.width >> 1;248 effectTips.anchorOffsetY = effectTips.height >> 1;249 effectTips.scaleX = 4;250 effectTips.scaleY = 4;251 if (!H5Core.stage.contains(effectTips)) {252 H5Core.stage.addChild(effectTips);253 }254 var onComplete2 = function () {255 if (H5Core.stage.contains(effectTips)) {256 H5Core.stage.removeChild(effectTips);257 effectTips = null;258 }259 };260 egret.Tween.get(effectTips).to({ scaleX: 1, scaleY: 1, alpha: 1 }, 200);261 egret.setTimeout(function () {262 egret.Tween.get(effectTips).to({ alpha: 0 }, 500).call(onComplete2, this);263 }, this, 1000);264 };265 return TextEffectsUtils;266}());...

Full Screen

Full Screen

pipeline.js

Source:pipeline.js Github

copy

Full Screen

1/**2 * Post-effects pipeline3 *4 * @author xeolabs / http://xeolabs.com5 *6 * IN DEVELOPMENT7 *8 * Usage example:9 *10 * someNode.addNode({11 * type: "postprocess/pipeline",12 * effects: [13 * {14 * effectId: "dof",15 * type: "postprocess/dof",16 * params: {17 * ppm: 10000.0,18 * blurCoeff: 0.00119 * },20 * enabled: true21 * },22 * {23 * effectId: "technicolor",24 * type: "postprocess/technicolor",25 * enabled: false26 * }27 * ]28 * },29 * function(pipeline) {30 *31 * pipeline.setEnabled({32 * dof: false,33 * technicolor: true34 * });35 * });36 */37SceneJS.Types.addType("postprocess/pipeline", {38 construct: function (params) {39 var self = this;40 /**41 * Effects in the order in which they will be applied42 *43 * @type {[{}]}44 */45 this.pipeline = [];46 /**47 * Effects mapped to their IDs48 *49 * @type {{}}50 */51 this.effects = {};52 // True when effects pipeline in the53 // scene graph needs to be rebuilt54 this._dirty = false;55 // Add effects56 if (params.effects) {57 for (var i = 0, len = params.effects.length; i < len; i++) {58 this.addEffect(params.effects[i]);59 }60 }61 if (params.enabled) {62 this.setEnabled(params.enabled);63 }64 if (params.params) {65 this.setParams(params.params);66 }67 this._subtree = this.addNode({68 id: this.id + ".subtree",69 nodes: params.nodes70 });71 this._needRebuild();72 },73 _needRebuild: function () {74 if (!this._tick) {75 var self = this;76 this._tick = this.getScene().once("tick",77 function () {78 self._rebuildScene();79 self._tick = null;80 });81 }82 },83 _rebuildScene: function () {84 // Disconnect scene content85 this._subtree.disconnect();86 // Blow away effect nodes87 this.removeNodes();88 // Rebuild effect nodes89 var effect;90 var json = {91 nodes: []92 };93 var node = json;94 var scene = this.getScene();95 for (var i = 0, len = this.pipeline.length; i < len; i++) {96 effect = this.pipeline[i];97 if (effect.enabled) {98 var effectId = this.id + "." + effect.effectId;99 var child = SceneJS._applyIf(effect.params, {100 type: effect.type,101 id: effectId,102 nodes: []103 });104 node.nodes.push(child);105 node = child;106 // Save scene node on effect for param updates107 scene.getNode(effectId,108 (function () {109 var _effect = effect;110 return function (node) {111 _effect.node = node;112 }113 })());114 } else {115 // No scene nodes exist for disabled effects116 effect.node = null;117 }118 }119 // Append scene content to lowest effect node, thus applying120 // all the effects to it, in order of each effect on the path121 // up to the scene root122 node.nodes.push({ id: this.id + ".effectsSubTree" });123 var self = this;124 this.addNode(json,125 function () {126 scene.getNode(this.id + ".effectsSubTree",127 function (leaf) {128 if (self._subtree.parent == null) {129 leaf.addNode(self._subtree);130 }131 });132 self._dirty = false;133 });134 },135 /**136 * Adds a effect137 * @param params138 */139 addEffect: function (params) {140 var effect = params;141 this.effects[params.effectId] = effect;142 this.pipeline.unshift(effect);143 this._needRebuild();144 },145 /**146 * Enables or disables effects147 * @param params148 */149 setEnabled: function (params) {150 // Option to replace the set of enabled effects151 if (params.replace) {152 for (var i = 0, len = this.pipeline.length; i < len; i++) {153 this.pipeline[i].enabled = false;154 }155 }156 var effect;157 if (params.effectId) {158 var effectId = params.effectId;159 effect = this.effects[effectId];160 if (!effect) {161 //Human.log.error("Human.view.effects.setEnabled", "Effect not found: " + effectId);162 return;163 }164 effect.enabled = !!params.enable;165 } else if (params.effectIds) {166 var effectIds = params.effectIds;167 var val;168 for (var effectId in effectIds) {169 if (effectIds.hasOwnProperty(effectId)) {170 effect = this.effects[effectId];171 if (!effect) {172 // Human.log.error("Human.view.effects.setEnabled", "Effect not found: " + effectId);173 continue;174 }175 val = effectIds[effectId];176 effect.enabled = !!val;177 if (val && typeof val !== "boolean") {178 // Effect params given179 // effect.setParams(val);180 }181 }182 }183 }184 this._needRebuild();185 },186 /**187 * Sets parameters for effects188 * @param params189 */190 setParams: function (params) {191 var effect;192 for (var effectId in params) {193 if (params.hasOwnProperty(effectId)) {194 effect = this.effects[effectId];195 if (!effect) {196 this.log("error", "Effect not found: " + effectId);197 continue;198 }199 SceneJS._apply(params, effect.params);200 if (effect.node) {201 effect.node.set(params[effectId]);202 }203 }204 }205 },206 _destruct: function () {207 this._subtree.destroy();208 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { useStorybookState, useStorybookApi } from '@storybook/api';2export const TestComponent = () => {3 const state = useStorybookState();4 const api = useStorybookApi();5 return (6 <button onClick={() => api.toggleFullscreen()}>Toggle Fullscreen</button>7 <pre>{JSON.stringify(state, null, 2)}</pre>8 );9};10module.exports = {11};12import { withRootProvider } from 'storybook-root-provider';13import Button from './Button';14export default {15};16export const Primary = () => <Button variant="primary">Primary</Button>;17MIT © [davidhazagury](

Full Screen

Using AI Code Generation

copy

Full Screen

1import { useEffect } from "@storybook/client-api";2export default {3 parameters: {4 },5};6export const Test = () => {7 useEffect(() => {8 console.log("test");9 }, []);10 return <div>Test</div>;11};

Full Screen

Using AI Code Generation

copy

Full Screen

1import { useEffect } from 'react';2import { useStorybookState } from '@storybook/api';3import { useChannel } from '@storybook/api';4import addons from '@storybook/addons';5export const withRootDecorator = (storyFn, context) => {6 const api = useStorybookState();7 const emit = useChannel({});8 useEffect(() => {9 addons.setConfig({10 });11 }, []);12 return storyFn(context);13};14import { withRootDecorator } from './test';15export const decorators = [withRootDecorator];16{17 "scripts": {18 }19}20{21 "scripts": {22 }23}24import { withRootDecorator } from './test';25export const decorators = [withRootDecorator];26{27 "scripts": {28 }29}30MIT © [kamleshchandnani](

Full Screen

Using AI Code Generation

copy

Full Screen

1import React from "react";2import { useStorybookRootProvider } from "storybook-root-provider";3import { useEffect } from "@storybook/addons";4export default {5};6export const Test = () => {7 const { setRoot } = useStorybookRootProvider();8 useEffect(() => {9 setRoot(<div>test</div>);10 }, []);11 return <div>test</div>;12};13import React from "react";14import { useStorybookRootProvider } from "storybook-root-provider";15import { useEffect } from "@storybook/addons";16export default {17};18export const Test2 = () => {19 const { setRoot } = useStorybookRootProvider();20 useEffect(() => {21 setRoot(<div>test2</div>);22 }, []);23 return <div>test2</div>;24};25import { addons } from "@storybook/addons";26import { rootProvider } from "storybook-addon-root-provider";27addons.setConfig({28});29import React from "react";30import { withRootProvider } from "storybook-addon-root-provider";31export const decorators = [withRootProvider];32import React from "react";33import { useStorybookRootProvider } from "storybook-root-provider";34import { useEffect } from "@storybook/addons";35export default {36};37export const Test = () => {38 const { setRoot } = useStorybookRootProvider();39 useEffect(() => {40 setRoot(<div>test</div>);41 }, []);42 return <div>test</div>;43};44import React from "react";45import { useStorybookRootProvider } from "storybook-root-provider";46import { useEffect } from "@storybook/addons";47export default {48};49export const Test2 = () => {50 const { setRoot

Full Screen

Using AI Code Generation

copy

Full Screen

1import React from 'react';2import { useStorybookRoot } from 'storybook-root-provider';3export const TestComponent = () => {4 const root = useStorybookRoot();5 const onClick = () => {6 root.setRootData('key', 'value');7 };8 return <button onClick={onClick}>Click me</button>;9};10import React from 'react';11import { withStorybookRoot } from 'storybook-root-provider';12import { TestComponent } from './test';13 withStorybookRoot({14 }),15];16import React from 'react';17import { withStorybookRoot } from 'storybook-root-provider';18import { TestComponent } from '../test';19 withStorybookRoot({20 }),21];22import React from 'react';23import { withStorybookRoot } from 'storybook-root-provider';24import { TestComponent } from '../test';25 withStorybookRoot({26 }),27];28import React from 'react';29import { withStorybookRoot } from 'storybook-root-provider';30import { TestComponent } from '../test';31 withStorybookRoot({32 }),33];34import React from 'react';35import { withStorybookRoot } from 'storybook-root-provider';36import { TestComponent } from '../test';37 withStorybookRoot({38 }),39];40import React from 'react';41import { withStorybookRoot } from 'storybook-root-provider';42import { TestComponent } from '../test';43 withStorybookRoot({44 }),45];

Full Screen

Using AI Code Generation

copy

Full Screen

1import { useStorybookEffect } from "storybook-root";2import { useEffect } from "react";3useStorybookEffect((storybook) => {4 useEffect(() => {5 storybook.add("test", () => <div>test</div>);6 });7});8MIT © [NathanBland](

Full Screen

Using AI Code Generation

copy

Full Screen

1import { useStorybookRoot } from 'storybook-root';2const Test = () => {3 const { setRootCss } = useStorybookRoot();4 const [isDark, setIsDark] = useState(false);5 const handleDarkMode = () => {6 if (isDark) {7 setRootCss({ '--bg-color': 'white', '--text-color': 'black' });8 } else {9 setRootCss({ '--bg-color': 'black', '--text-color': 'white' });10 }11 setIsDark(!isDark);12 };13 return (14 <button onClick={handleDarkMode}>{isDark ? 'Light Mode' : 'Dark Mode'}</button>15 );16};17export default Test;18MIT © [sahiljain112](

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root 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