How to use navigate method in storybook-root

Best JavaScript code snippet using storybook-root

CW3.py

Source:CW3.py Github

copy

Full Screen

1from BrickPi import *2import particleDataStructures3import basic4from numpy import cos, sin, pi, arctan, sqrt, exp, arccos, arctan25import random6import place_rec_bits7global signatures8distSonarToCenter = 139robotX = float(84.0)10robotY = float(30.0)11robotA = float(0.0)12nbOfParticles = 3013mult = 314particleSet = []15sonarVar = 316def lineToCoord(x0, y0, x1, y1):17 middleX = 100.018 middleY = 700.019 print "drawLine:"+str( (middleX + mult * x0, middleY - mult * y0, middleX + mult * x1, middleY - mult * y1) )20def particlesToCoord(particleSet):21 middleX = 100.022 middleY = 700.023 particles = [(mult * particleSet[i][0] + middleX, - mult * particleSet[i][1]+middleY, particleSet[i][2]) for i in range(nbOfParticles)]24 print "drawParticles:" + str(particles)25 26def meanParticles():27 global particleSet28 meanX = 029 meanY = 030 meanSinT = 031 meanCosT = 032 i = 033 while i < nbOfParticles:34 meanX += particleSet[i][0]*particleSet[i][3]35 meanY += particleSet[i][1]*particleSet[i][3]36 meanSinT += sin(particleSet[i][2]*pi/180)*particleSet[i][3]37 meanCosT += cos(particleSet[i][2]*pi/180)*particleSet[i][3]38 i += 139 meanT = arctan2(meanSinT, meanCosT)*180/pi40 #meanX /= nbOfParticles41 #meanY /= nbOfParticles42 #meanT /= nbOfParticles43 return (meanX, meanY, meanT)44def particleInit():45 global particleSet46 i = 047 particleSet = []48 while i < nbOfParticles:49 particleSet.append([robotX, robotY, robotA, 1.0/nbOfParticles])50 i += 151 return particleSet52def updateSL(D, sigma1, sigma2):53 global particleSet, robotX, robotY,robotA54 i = 055 #robotXn = robotX + float(D) *cos(robotA / 180 * pi)56 #robotYn = robotY + float(D) *sin(robotA / 180 * pi)57 while i < nbOfParticles:58 e = random.gauss(0, sigma1)59 f = random.gauss(0, sigma2)60 particleSet[i][0] += (D+e)*cos(particleSet[i][2] / 180 * pi) 61 particleSet[i][1] += (D+e)*sin(particleSet[i][2] / 180 * pi)62 particleSet[i][2] += f63 particleSet[i][2] = particleSet[i][2] % 36064 i += 165 updateParticlesSonar()66 mean = meanParticles()67 canvas.drawLine( (robotX, robotY, mean[0], mean[1]) )68 robotX = mean[0]69 robotY = mean[1]70 robotA = mean[2]71 #particlesToCoord(particleSet)72def updateR(a, sigma):73 global particleSet,robotA74 robotA = (robotA + a)%36075 i = 076 while i < nbOfParticles:77 g = random.gauss(0, sigma)78 particleSet[i][2] += a + g79 particleSet[i][2] = particleSet[i][2]%36080 i +=181def driveLine(distance):82 basic.move(-distance)83 updateSL(distance, 1, 0.5)84 85def rotation(degree):86 basic.turn(degree)87 updateR(degree, abs(degree/90*2.6))88def square():89 driveLine(40)90 rotation(90)91 driveLine(40)92 rotation(90)93 driveLine(40)94 rotation(90)95 driveLine(40)96 rotation(90)97def sonarMeasure():98 while True:99 result = BrickPiUpdateValues()100 if not result:101 print basic.measureSonar() 102 time.sleep(0.1)103 104def navigateToWaypoint(X, Y):105 (x, y , t) = meanParticles()106 print "Estimate direction is = ", t107 print "aim to: ", (X,Y), " from ", str((x,y,t))108 diffX = (X - x) 109 diffY = (Y - y)110 dist = sqrt(diffX*diffX + diffY*diffY)111 aimAngle = arctan(diffY / diffX) if (diffX != 0) else pi/2 if (diffY >= 0) else -pi/2112 if diffX < 0:113 aimAngle += pi114 #ux = cos(t*pi/180)115 #uy = sin(t*pi/180)116 #angle = -arctan((diffX*ux + diffY*uy)/(diffX*uy - diffY*ux))117 118 print aimAngle*180/pi - t119 rotAngle = aimAngle*180/pi - t120 if (rotAngle > 180):121 while rotAngle > 180:122 rotAngle -= 360123 elif (rotAngle < -180):124 while rotAngle < -180:125 rotAngle += 360 126 print dist127 rotation(rotAngle)128 driveLine(dist)129 correction = True130 if correction:131 (x, y , t) = meanParticles() 132 (m, wall, beta) = getFacingWall(X, Y, t)133 z = basic.measureSonar()134 z += distSonarToCenter135 if (abs(m - z) > 5 and z < 250 and beta < 30):136 driveLine(z-m)137 138def calculate_likelihood(x, y, theta, z):139 measure = getFacingWall(x,y,theta)140 #print measure141 if len(measure) == 1:142 return 0143 elif ( z >= 255 or abs(measure[2]) > 60 ):144 return 0.3145 else:146 diffMZ = measure[0] - z147 pZM = exp(-diffMZ*diffMZ/(2*sonarVar*sonarVar)) + 0.05148 return pZM149def intersection(x, y, theta, wall):150 if (theta != 90 and theta != 270):151 a = sin(theta * pi / 180)/cos(theta * pi / 180)152 b = y - a * x153 else:154 a = 0155 b = y156 if (wall[0] == wall[2]):157 intersectionY = a*wall[0] + b158 if ( (wall[1] <= intersectionY <= wall[3]) or (wall[3] <= intersectionY <= wall[1]) ):159 return True160 else:161 return False162 else:163 if a == 0:164 if ( (wall[0] <= x <= wall[2]) or (wall[2] <= x <= wall[0]) ):165 return True166 else:167 return False168 else:169 intersectionX = (wall[1] - b)/a170 if ( (wall[0] <= intersectionX <= wall[2]) or (wall[2] <= intersectionX <= wall[0]) ):171 return True172 else:173 return False174def getFacingWall(x,y,theta):175 global mymap176 walls = mymap.walls177 measures = []178 if insideTheMap(x,y):179 for wall in walls:180 m = (wall[3] - wall[1])*(wall[0] - x) - (wall[2] - wall[0])*(wall[1] - y)181 d = (wall[3] - wall[1])*cos(theta * pi / 180) - (wall[2] - wall[0])*sin(theta * pi / 180) 182 m = ((m / d) if d != 0 else 0)183 beta = 180*arccos( (cos(theta*pi/180) * (wall[1] - wall[3]) + sin(theta*pi/180) * (wall[2] - wall[0])) / sqrt( (wall[1] - wall[3]) * (wall[1] - wall[3]) + (wall[2] - wall[0]) * (wall[2] - wall[0])) )/pi184 if(m > 0):185 measures.append((m,wall, beta))186 sorted_measures = sorted(measures, key = lambda tup: tup[0])187 for meas in sorted_measures:188 if intersection(x, y, theta, meas[1]):189 return meas190 else:191 return [0]192 return None # should never happen!!193def insideTheMap(x,y):194 if (x < 0):195 return False196 elif (y < 0):197 return False198 elif (0 <= x <= 84 and y > 168):199 return False200 elif (84 <= x <= 168 and y > 210):201 return False202 elif (168 <= x <= 210 and y > 84):203 return False204 elif x > 210:205 return False206 else:207 return True208def updateParticlesSonar():209 global particleSet, nbOfParticles210 z = basic.measureSonar()211 z += distSonarToCenter212 weightSum = 0213 for particle in particleSet:214 particle[3] *= calculate_likelihood(particle[0], particle[1], particle[2], z)215 weightSum += particle[3]216 for particle in particleSet:217 particle[3] /= weightSum218 cumulativeProbability = [0] * nbOfParticles219 cumulativeProbability[0] = particleSet[0][3]220 i = 1221 while i < nbOfParticles:222 cumulativeProbability[i] = cumulativeProbability[i-1] + particleSet[i][3]223 i += 1224 i = 0225 newParticleSet = []226 while i < nbOfParticles:227 r = random.random()228 j = 0229 while r > cumulativeProbability[j]:230 j += 1231 newParticleSet.append( [particleSet[j][0], particleSet[j][1], particleSet[j][2], 1.0/nbOfParticles] )232 i += 1233 particleSet = newParticleSet234def routine():235 particleTuple = [tuple(l)[0:3] for l in particleSet]236 particles.data = particleTuple237 particles.draw()238 navigateToWaypoint(180, 30)239 updateParticlesSonar()240 particleTuple = [tuple(l)[0:3] for l in particleSet]241 particles.data = particleTuple242 particles.draw()243 navigateToWaypoint(180, 54)244 updateParticlesSonar()245 particleTuple = [tuple(l)[0:3] for l in particleSet]246 particles.data = particleTuple247 particles.draw()248 navigateToWaypoint(126, 54)249 updateParticlesSonar()250 particleTuple = [tuple(l)[0:3] for l in particleSet]251 particles.data = particleTuple252 particles.draw()253 navigateToWaypoint(126, 168)254 updateParticlesSonar()255 particleTuple = [tuple(l)[0:3] for l in particleSet]256 particles.data = particleTuple257 particles.draw()258 navigateToWaypoint(126, 126)259 updateParticlesSonar()260 particleTuple = [tuple(l)[0:3] for l in particleSet]261 particles.data = particleTuple262 particles.draw()263 navigateToWaypoint(30, 54)264 updateParticlesSonar()265 particleTuple = [tuple(l)[0:3] for l in particleSet]266 particles.data = particleTuple267 particles.draw()268 navigateToWaypoint(84, 54)269 updateParticlesSonar()270 particleTuple = [tuple(l)[0:3] for l in particleSet]271 particles.data = particleTuple272 particles.draw()273 navigateToWaypoint(84, 30)274 updateParticlesSonar()275 particleTuple = [tuple(l)[0:3] for l in particleSet]276 particles.data = particleTuple277 particles.draw()278def challenge():279 global robotX, robotY, robotA, signatures280 s = raw_input('Press ENTER to launch the robot !')281 index, angle = place_rec_bits.recognize_location_challenge()282 print "We are in location " + str(index) + " with an orientation of " + str(angle) + " degrees."283 x1 = 84284 y1 = 30285 286 x2 = 180287 y2 = 30288 x4 = 126289 y4 = 54290 x5 = 126291 y5 = 168292 x6 = 126293 y6 = 126294 x7 = 30295 y7 = 54296 # We consider the best path to be :297 # 1 <-> 2 <-> 4 <-> 5 <-> 6 <-> 7 <-> 1298 # initialize the robot location299 if index == 1:300 robotX = float(84.0)301 robotY = float(30.0)302 robotA = float(angle)303 elif index == 2:304 robotX = float(180.0)305 robotY = float(30.0)306 robotA = float(angle)307 elif index == 3:308 robotX = float(126.0)309 robotY = float(54.0)310 robotA = float(angle)311 elif index == 4:312 robotX = float(126.0)313 robotY = float(168.0)314 robotA = float(angle)315 else:316 robotX = float(30.0)317 robotY = float(54.0)318 robotA = float(angle)319 particleInit()320 basic.move(-13)321 # let's roll!322 if index == 1:323 if (angle > 78 and angle < 234):324 navigateToWaypoint(x7, y7)325 basic.blink()326 updateParticlesSonar()327 navigateToWaypoint(x6, y6)328 updateParticlesSonar()329 navigateToWaypoint(x5, y5)330 basic.blink()331 updateParticlesSonar()332 navigateToWaypoint(x4, y4)333 basic.blink()334 updateParticlesSonar()335 navigateToWaypoint(x2, y2)336 basic.blink()337 updateParticlesSonar()338 navigateToWaypoint(x1, y1)339 basic.blink()340 else:341 navigateToWaypoint(x2, y2)342 basic.blink()343 updateParticlesSonar()344 navigateToWaypoint(x4, y4)345 basic.blink()346 updateParticlesSonar()347 navigateToWaypoint(x5, y5)348 basic.blink()349 updateParticlesSonar()350 navigateToWaypoint(x6, y6)351 updateParticlesSonar()352 navigateToWaypoint(x7, y7)353 basic.blink()354 updateParticlesSonar()355 navigateToWaypoint(x1, y1)356 basic.blink()357 elif index == 2:358 if (angle > 168 and angle < 348):359 navigateToWaypoint(x1, y1)360 basic.blink()361 updateParticlesSonar()362 navigateToWaypoint(x7, y7)363 basic.blink()364 updateParticlesSonar()365 navigateToWaypoint(x6, y6)366 updateParticlesSonar()367 navigateToWaypoint(x5, y5)368 basic.blink()369 updateParticlesSonar()370 navigateToWaypoint(x4, y4)371 basic.blink()372 updateParticlesSonar()373 navigateToWaypoint(x2, y2)374 basic.blink()375 else:376 navigateToWaypoint(x4, y4)377 basic.blink()378 updateParticlesSonar()379 navigateToWaypoint(x5, y5)380 basic.blink()381 updateParticlesSonar()382 navigateToWaypoint(x6, y6)383 updateParticlesSonar()384 navigateToWaypoint(x7, y7)385 basic.blink()386 updateParticlesSonar()387 navigateToWaypoint(x1, y1)388 basic.blink()389 updateParticlesSonar()390 navigateToWaypoint(x2, y2)391 basic.blink()392 elif index == 3:393 if (angle > 33 and angle < 213):394 navigateToWaypoint(x5, y5)395 basic.blink()396 updateParticlesSonar()397 navigateToWaypoint(x6, y6)398 updateParticlesSonar()399 navigateToWaypoint(x7, y7)400 basic.blink()401 updateParticlesSonar()402 navigateToWaypoint(x1, y1)403 basic.blink()404 updateParticlesSonar()405 navigateToWaypoint(x2, y2)406 basic.blink()407 updateParticlesSonar()408 navigateToWaypoint(x4, y4)409 basic.blink()410 else:411 navigateToWaypoint(x2, y2)412 basic.blink()413 updateParticlesSonar()414 navigateToWaypoint(x1, y1)415 basic.blink()416 updateParticlesSonar()417 navigateToWaypoint(x7, y7)418 basic.blink()419 updateParticlesSonar()420 navigateToWaypoint(x6, y6)421 updateParticlesSonar()422 navigateToWaypoint(x5, y5)423 basic.blink()424 updateParticlesSonar()425 navigateToWaypoint(x4, y4)426 basic.blink()427 elif index == 4:428 navigateToWaypoint(x6, y6)429 updateParticlesSonar()430 431 navigateToWaypoint(x7, y7)432 basic.blink()433 updateParticlesSonar()434 navigateToWaypoint(x1, y1)435 basic.blink()436 updateParticlesSonar()437 navigateToWaypoint(x2, y2)438 basic.blink()439 updateParticlesSonar()440 navigateToWaypoint(x4, y4)441 basic.blink()442 updateParticlesSonar()443 navigateToWaypoint(x5, y5)444 basic.blink()445 else:446 if (angle > 6 and angle < 186):447 navigateToWaypoint(x6, y6)448 updateParticlesSonar()449 navigateToWaypoint(x5, y5)450 basic.blink()451 updateParticlesSonar()452 navigateToWaypoint(x4, y4)453 basic.blink()454 updateParticlesSonar()455 navigateToWaypoint(x2, y2)456 basic.blink()457 updateParticlesSonar()458 navigateToWaypoint(x1, y1)459 basic.blink()460 updateParticlesSonar()461 navigateToWaypoint(x7, y7)462 basic.blink()463 else:464 navigateToWaypoint(x1, y1)465 basic.blink()466 updateParticlesSonar()467 navigateToWaypoint(x2, y2)468 basic.blink()469 updateParticlesSonar()470 navigateToWaypoint(x4, y4)471 basic.blink()472 updateParticlesSonar()473 navigateToWaypoint(x5, y5)474 basic.blink()475 updateParticlesSonar()476 navigateToWaypoint(x6, y6)477 updateParticlesSonar()478 navigateToWaypoint(x7, y7)479 basic.blink()480## MAIN ##481basic.setupSensors()482particles = particleDataStructures.Particles()483particleSet = particleInit()484particleTuple = [tuple(l)[0:3] for l in particleSet]485particles.data = particleTuple486#particles.draw()487canvas = particleDataStructures.Canvas(); # global canvas we are going to draw on488mymap = particleDataStructures.Map();489# Definitions of walls490# a: O to A491# b: A to B492# c: C to D493# d: D to E494# e: E to F495# f: F to G496# g: G to H497# h: H to O498mymap.add_wall((0,0,0,168)); # a499mymap.add_wall((0,168,84,168)); # b500mymap.add_wall((84,126,84,210)); # c501mymap.add_wall((84,210,168,210)); # d502mymap.add_wall((168,210,168,84)); # e503mymap.add_wall((168,84,210,84)); # f504mymap.add_wall((210,84,210,0)); # g505mymap.add_wall((210,0,0,0)); # h506#mymap.draw();507#basic.move(100)508#time.sleep(1)509#basic.genericMove(100, -100, 100)510#basic.turn(90)511#driveLine(particleSet)512#leftRotation(particleSet)513#square()514#basic.turn(360)515#navigateToWaypoint(50,50)516#navigateToWaypoint(50, -20)517#navigateToWaypoint(60, 0)518#navigateToWaypoint(0,0)519#sonarMeasure()520#routine()...

Full Screen

Full Screen

controls.js

Source:controls.js Github

copy

Full Screen

1import { queryAll } from '../utils/util.js'2import { isAndroid } from '../utils/device.js'3/**4 * Manages our presentation controls. This includes both5 * the built-in control arrows as well as event monitoring6 * of any elements within the presentation with either of the7 * following helper classes:8 * - .navigate-up9 * - .navigate-right10 * - .navigate-down11 * - .navigate-left12 * - .navigate-next13 * - .navigate-prev14 */15export default class Controls {16 constructor( Reveal ) {17 this.Reveal = Reveal;18 this.onNavigateLeftClicked = this.onNavigateLeftClicked.bind( this );19 this.onNavigateRightClicked = this.onNavigateRightClicked.bind( this );20 this.onNavigateUpClicked = this.onNavigateUpClicked.bind( this );21 this.onNavigateDownClicked = this.onNavigateDownClicked.bind( this );22 this.onNavigatePrevClicked = this.onNavigatePrevClicked.bind( this );23 this.onNavigateNextClicked = this.onNavigateNextClicked.bind( this );24 }25 render() {26 const rtl = this.Reveal.getConfig().rtl;27 const revealElement = this.Reveal.getRevealElement();28 this.element = document.createElement( 'aside' );29 this.element.className = 'controls';30 this.element.innerHTML =31 `<button class="navigate-left" aria-label="${ rtl ? 'next slide' : 'previous slide' }"><div class="controls-arrow"></div></button>32 <button class="navigate-right" aria-label="${ rtl ? 'previous slide' : 'next slide' }"><div class="controls-arrow"></div></button>33 <button class="navigate-up" aria-label="above slide"><div class="controls-arrow"></div></button>34 <button class="navigate-down" aria-label="below slide"><div class="controls-arrow"></div></button>`;35 this.Reveal.getRevealElement().appendChild( this.element );36 // There can be multiple instances of controls throughout the page37 this.controlsLeft = queryAll( revealElement, '.navigate-left' );38 this.controlsRight = queryAll( revealElement, '.navigate-right' );39 this.controlsUp = queryAll( revealElement, '.navigate-up' );40 this.controlsDown = queryAll( revealElement, '.navigate-down' );41 this.controlsPrev = queryAll( revealElement, '.navigate-prev' );42 this.controlsNext = queryAll( revealElement, '.navigate-next' );43 // The left, right and down arrows in the standard reveal.js controls44 this.controlsRightArrow = this.element.querySelector( '.navigate-right' );45 this.controlsLeftArrow = this.element.querySelector( '.navigate-left' );46 this.controlsDownArrow = this.element.querySelector( '.navigate-down' );47 }48 /**49 * Called when the reveal.js config is updated.50 */51 configure( config, oldConfig ) {52 this.element.style.display = config.controls ? 'block' : 'none';53 this.element.setAttribute( 'data-controls-layout', config.controlsLayout );54 this.element.setAttribute( 'data-controls-back-arrows', config.controlsBackArrows );55 }56 bind() {57 // Listen to both touch and click events, in case the device58 // supports both59 let pointerEvents = [ 'touchstart', 'click' ];60 // Only support touch for Android, fixes double navigations in61 // stock browser62 if( isAndroid ) {63 pointerEvents = [ 'touchstart' ];64 }65 pointerEvents.forEach( eventName => {66 this.controlsLeft.forEach( el => el.addEventListener( eventName, this.onNavigateLeftClicked, false ) );67 this.controlsRight.forEach( el => el.addEventListener( eventName, this.onNavigateRightClicked, false ) );68 this.controlsUp.forEach( el => el.addEventListener( eventName, this.onNavigateUpClicked, false ) );69 this.controlsDown.forEach( el => el.addEventListener( eventName, this.onNavigateDownClicked, false ) );70 this.controlsPrev.forEach( el => el.addEventListener( eventName, this.onNavigatePrevClicked, false ) );71 this.controlsNext.forEach( el => el.addEventListener( eventName, this.onNavigateNextClicked, false ) );72 } );73 }74 unbind() {75 [ 'touchstart', 'click' ].forEach( eventName => {76 this.controlsLeft.forEach( el => el.removeEventListener( eventName, this.onNavigateLeftClicked, false ) );77 this.controlsRight.forEach( el => el.removeEventListener( eventName, this.onNavigateRightClicked, false ) );78 this.controlsUp.forEach( el => el.removeEventListener( eventName, this.onNavigateUpClicked, false ) );79 this.controlsDown.forEach( el => el.removeEventListener( eventName, this.onNavigateDownClicked, false ) );80 this.controlsPrev.forEach( el => el.removeEventListener( eventName, this.onNavigatePrevClicked, false ) );81 this.controlsNext.forEach( el => el.removeEventListener( eventName, this.onNavigateNextClicked, false ) );82 } );83 }84 /**85 * Updates the state of all control/navigation arrows.86 */87 update() {88 let routes = this.Reveal.availableRoutes();89 // Remove the 'enabled' class from all directions90 [...this.controlsLeft, ...this.controlsRight, ...this.controlsUp, ...this.controlsDown, ...this.controlsPrev, ...this.controlsNext].forEach( node => {91 node.classList.remove( 'enabled', 'fragmented' );92 // Set 'disabled' attribute on all directions93 node.setAttribute( 'disabled', 'disabled' );94 } );95 // Add the 'enabled' class to the available routes; remove 'disabled' attribute to enable buttons96 if( routes.left ) this.controlsLeft.forEach( el => { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );97 if( routes.right ) this.controlsRight.forEach( el => { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );98 if( routes.up ) this.controlsUp.forEach( el => { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );99 if( routes.down ) this.controlsDown.forEach( el => { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );100 // Prev/next buttons101 if( routes.left || routes.up ) this.controlsPrev.forEach( el => { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );102 if( routes.right || routes.down ) this.controlsNext.forEach( el => { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );103 // Highlight fragment directions104 let currentSlide = this.Reveal.getCurrentSlide();105 if( currentSlide ) {106 let fragmentsRoutes = this.Reveal.fragments.availableRoutes();107 // Always apply fragment decorator to prev/next buttons108 if( fragmentsRoutes.prev ) this.controlsPrev.forEach( el => { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );109 if( fragmentsRoutes.next ) this.controlsNext.forEach( el => { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );110 // Apply fragment decorators to directional buttons based on111 // what slide axis they are in112 if( this.Reveal.isVerticalSlide( currentSlide ) ) {113 if( fragmentsRoutes.prev ) this.controlsUp.forEach( el => { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );114 if( fragmentsRoutes.next ) this.controlsDown.forEach( el => { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );115 }116 else {117 if( fragmentsRoutes.prev ) this.controlsLeft.forEach( el => { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );118 if( fragmentsRoutes.next ) this.controlsRight.forEach( el => { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );119 }120 }121 if( this.Reveal.getConfig().controlsTutorial ) {122 let indices = this.Reveal.getIndices();123 // Highlight control arrows with an animation to ensure124 // that the viewer knows how to navigate125 if( !this.Reveal.hasNavigatedVertically() && routes.down ) {126 this.controlsDownArrow.classList.add( 'highlight' );127 }128 else {129 this.controlsDownArrow.classList.remove( 'highlight' );130 if( this.Reveal.getConfig().rtl ) {131 if( !this.Reveal.hasNavigatedHorizontally() && routes.left && indices.v === 0 ) {132 this.controlsLeftArrow.classList.add( 'highlight' );133 }134 else {135 this.controlsLeftArrow.classList.remove( 'highlight' );136 }137 } else {138 if( !this.Reveal.hasNavigatedHorizontally() && routes.right && indices.v === 0 ) {139 this.controlsRightArrow.classList.add( 'highlight' );140 }141 else {142 this.controlsRightArrow.classList.remove( 'highlight' );143 }144 }145 }146 }147 }148 /**149 * Event handlers for navigation control buttons.150 */151 onNavigateLeftClicked( event ) {152 event.preventDefault();153 this.Reveal.onUserInput();154 if( this.Reveal.getConfig().navigationMode === 'linear' ) {155 this.Reveal.prev();156 }157 else {158 this.Reveal.left();159 }160 }161 onNavigateRightClicked( event ) {162 event.preventDefault();163 this.Reveal.onUserInput();164 if( this.Reveal.getConfig().navigationMode === 'linear' ) {165 this.Reveal.next();166 }167 else {168 this.Reveal.right();169 }170 }171 onNavigateUpClicked( event ) {172 event.preventDefault();173 this.Reveal.onUserInput();174 this.Reveal.up();175 }176 onNavigateDownClicked( event ) {177 event.preventDefault();178 this.Reveal.onUserInput();179 this.Reveal.down();180 }181 onNavigatePrevClicked( event ) {182 event.preventDefault();183 this.Reveal.onUserInput();184 this.Reveal.prev();185 }186 onNavigateNextClicked( event ) {187 event.preventDefault();188 this.Reveal.onUserInput();189 this.Reveal.next();190 }...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...118 label="INITIAL APPLICATION"119 progress={stage0Progress}120 navigate={121 BASE_URL === DEV_URL122 ? () => navigation.navigate(APPLY_NOW_NAV)123 : !this.shouldNavigateToStage(0)124 ? () => navigation.navigate(APPLY_NOW_NAV)125 : null126 }127 />128 <StageProgressSection129 label="STAGE 1"130 progress={stage1Progress}131 navigate={132 this.shouldNavigateToStage(0)133 ? application_type === (NEW_APPLICANT || DIRECT_PLACEMENT)134 ? INTERVIEW_STATUS_TITLE[status] !==135 INTERVIEW_STATUS_TITLE[1] && stage1Progress === 100136 ? () => navigation.navigate(STAGE_ONE_FORM)137 : () => navigation.navigate(STAGE_ONE_NAV)138 : stage1Progress === 100139 ? () => navigation.navigate(STAGE_ONE_FORM)140 : () => navigation.navigate(STAGE_ONE_NAV)141 : null142 }143 />144 <StageProgressSection145 label="STAGE 2"146 progress={stage2Progress}147 navigate={148 (application_type === RETURN_TO_CAMP149 ? stage1Progress === 100150 : status === INTERVIEW_STATUS.confirmed)151 ? stage2Progress !== 100152 ? () => navigation.navigate(STAGE_TWO_NAV)153 : () => navigation.navigate(STAGE_TWO_FORM)154 : stage1Progress === 100155 ? () =>156 //Toast.show(157 application_type === RETURN_TO_CAMP158 ? "You Have To Complete Stage One First"159 : `Can not pass because your interview status is ${INTERVIEW_STATUS_TITLE[status]}`160 )161 : null162 }163 />164 <StageProgressSection165 label="STAGE 3"166 progress={stage3Progress}167 navigate={168 this.shouldNavigateToStage(2)169 ? stage3Progress !== 100170 ? () => navigation.navigate(STAGE_THREE_NAV)171 : () => navigation.navigate(STAGE_THREE_FORM)172 : null173 }174 />175 <StageProgressSection176 label="STAGE 4"177 progress={stage4Progress}178 navigate={179 this.shouldNavigateToStage(3)180 ? stage4Progress !== 100181 ? () => navigation.navigate(STAGE_FOUR_NAV)182 : () => navigation.navigate(STAGE_FOUR_FORM)183 : null184 }185 />186 </ApplicationStatusSceen>187 </View>188 {/* content end */}189 {/* Bottom buttons or logo */}190 <View key="bottomLeft">191 <BottomButtonLeft onPress={() => navigation.navigate(DASHBOARD)}>192 HOME193 </BottomButtonLeft>194 </View>195 <View key="bottomRight">196 <BottomButtonRight197 onPress={198 selectedStage ? () => navigation.navigate(selectedStage) : null199 }200 >201 NEXT202 </BottomButtonRight>203 </View>204 {/* bottom end */}205 </Card>206 </View>207 );208 }209}210const mapStateToProps = ({211 stageProgress,212 interview: { status },...

Full Screen

Full Screen

EventBrowserTabController.py

Source:EventBrowserTabController.py Github

copy

Full Screen

...41 42 def refresh(self):43 eventNum=self._dataAccessor.eventNumber()44 self._fileModifcationTimestamp = os.path.getmtime(self._filename)45 self.navigate(0)46 self.navigate(eventNum)47 48 def readFile(self, filename):49 """ Reads in the file in a separate thread.50 """51 self.cancel()52 self._thread = ThreadChain(self.dataAccessor().open, filename)53 while self._thread.isRunning():54 if not Application.NO_PROCESS_EVENTS:55 QCoreApplication.instance().processEvents()56 if self._thread.returnValue():57 self.updateEventNumberDisplay()58 return True59 return False60 def isBusy(self):61 return BrowserTabController.isBusy(self) or\62 (self._thread and self._thread.isRunning())63 def navigate(self,to):64 # remember if navigation is ongoing65 navigating=self._navigateTo66 # set where to navigate67 self._navigateTo=to68 # if navigation is ongoing return69 if navigating!=None:70 return71 # if window is busy navigate later72 if self.isBusy():73 self.emit(SIGNAL("navigate"),to)74 return75 update=False76 while self._navigateTo!=None:77 current=self._navigateTo78 if self._navigateTo==0: 79 statusMessage = self.plugin().application().startWorking("Reopening file")80 self.dataAccessor().close()81 self.readFile(self._filename)82 else:83 statusMessage = self.plugin().application().startWorking("Navigate in file")84 if self._dataAccessor.goto(self._navigateTo):85 update=True86 if current==self._navigateTo:87 self._navigateTo=None88 if update:89 self.updateContent()90 self.updateEventNumberDisplay()91 self.plugin().application().stopWorking(statusMessage)92 def first(self):93 """ Navigate and to first event.94 """95 logging.debug(__name__ + ": first")96 self.cancel()97 currentEvent=self.dataAccessor().eventNumber()98 if currentEvent>1:99 self.navigate(1)100 def previous(self):101 """ Navigate and to previous event.102 """103 logging.debug(__name__ + ": previous")104 self.cancel()105 currentEvent=self.dataAccessor().eventNumber()106 if currentEvent>1:107 self.navigate(currentEvent-1)108 def next(self):109 """ Navigate and to next event.110 """111 logging.debug(__name__ + ": next")112 self.cancel()113 currentEvent=self.dataAccessor().eventNumber()114 allEvents=self.dataAccessor().numberOfEvents()115 if allEvents==None:116 allEvents=sys.maxint117 if currentEvent<allEvents:118 self.navigate(currentEvent+1)119 def last(self):120 """ Navigate and to last event.121 """122 logging.debug(__name__ + ": last")123 self.cancel()124 currentEvent=self.dataAccessor().eventNumber()125 allEvents=self.dataAccessor().numberOfEvents()126 if allEvents==None:127 allEvents=sys.maxint128 if currentEvent<allEvents:129 self.navigate(allEvents)130 def goto(self, number=None):131 """ Ask event number in dialog and navigate and to event.132 """133 logging.debug(__name__ + ": goto")134 if self._dataAccessor.numberOfEvents():135 max = self._dataAccessor.numberOfEvents()136 else:137 max = sys.maxint138 if number!=None:139 ok=(number>=1, number<=max)140 else:141 if hasattr(QInputDialog, "getInteger"):142 # Qt 4.3143 (number, ok) = QInputDialog.getInteger(self.plugin().application().mainWindow(), "Goto...", "Enter event number:", self._dataAccessor.eventNumber(), 1, max)144 else:145 # Qt 4.5146 (number, ok) = QInputDialog.getInt(self.plugin().application().mainWindow(), "Goto...", "Enter event number:", self._dataAccessor.eventNumber(), 1, max)147 if ok:148 self.cancel()149 currentEvent=self.dataAccessor().eventNumber()150 if currentEvent!=number:151 self.navigate(number)152 def updateEventNumberDisplay(self):153 eventDisplayString = str(self._dataAccessor.eventNumber()) + "/"154 if self._dataAccessor.numberOfEvents():155 eventDisplayString += str(self._dataAccessor.numberOfEvents())156 else:157 eventDisplayString += "?"...

Full Screen

Full Screen

Pricing.js

Source:Pricing.js Github

copy

Full Screen

1import React, { Component } from 'react'2import {3 View,4 BackAndroid,5 NavigationExperimental6} from 'react-native'7import {Utils as util, defineNextScene} from '../util'8import { SCENES } from '../constants/Scenes'9import {CompletePostScreen, CreatePost, DataScraping, MoreInfo, Options, PostScreen, Pricing, RegisterSeller} from '../screens/Pricing'10import {OAuthLogin, WelcomeScreen} from '../screens/Login'11const {12 CardStack: NavigationCardStack13} = NavigationExperimental14export default class PricingNavigator extends Component {15 constructor (props) {16 super(props)17 this._renderScene = this._renderScene.bind(this)18 this._handleBackAction = this._handleBackAction.bind(this)19 }20 componentDidMount () {21 BackAndroid.addEventListener('hardwareBackPress', this._handleBackAction)22 }23 componentWillUnmount () {24 BackAndroid.removeEventListener('hardwareBackPress', this._handleBackAction)25 }26 _renderScene (props) {27 const { route } = props.scene28 // console.log('NavPricing', route)29 switch (route.key) {30 case SCENES.CreatePost.toString():31 return <CreatePost route={route} _handleNavigate={this._handleNavigate.bind(this)}/>32 case SCENES.DataScraping.toString():33 return <DataScraping route={route} _handleNavigate={this._handleNavigate.bind(this)}/>34 case SCENES.Options.toString():35 return <Options route={route} _handleNavigate={this._handleNavigate.bind(this)}/>36 case SCENES.MoreInfo.toString():37 return <MoreInfo route={route} _handleNavigate={this._handleNavigate.bind(this)}/>38 case SCENES.Pricing.toString():39 return <Pricing route={route} _handleNavigate={this._handleNavigate.bind(this)}/>40 case SCENES.OAuthLogin.toString():41 return <OAuthLogin route={route} _handleNavigate={this._handleNavigate.bind(this)}/>42 case SCENES.WelcomeScreen.toString():43 return <WelcomeScreen route={route} _handleNavigate={this._handleNavigate.bind(this)}/>44 case SCENES.RegisterSeller.toString():45 return <RegisterSeller route={route} _handleNavigate={this._handleNavigate.bind(this)}/>46 case SCENES.PostScreen.toString():47 return <PostScreen route={route} _handleNavigate={this._handleNavigate.bind(this)}/>48 case SCENES.CompletePostScreen.toString():49 return <CompletePostScreen route={route} _handleNavigate={this._handleNavigate.bind(this)}/>50 default:51 return null52 }53 }54 _handleBackAction () {55 if (this.props.navigation.index === 0) {56 return false57 }58 this.props.popRoute()59 return true60 }61 _handleNavigate (action, data, nextSceneHelper) {62 if(typeof action === 'symbol') {63 action = defineNextScene.pricing(action, nextSceneHelper)64 }65 // console.log('NavPricing._handleNavigate → ', action, data, nextSceneHelper)66 if(action == null) {67 console.warn('last scene')68 return false69 }70 switch (action && action.type) {71 case 'push':72 this.props.pushRoute(action.route, data)73 return true74 case 'back':75 case 'pop':76 return this._handleBackAction()77 default:78 return false79 }80 }81 render () {82 return (83 <NavigationCardStack84 navigationState={this.props.navigation}85 onNavigate={this._handleNavigate.bind(this)}86 renderScene={this._renderScene} />87 )88 }...

Full Screen

Full Screen

Splash.js

Source:Splash.js Github

copy

Full Screen

1import React, { Component } from 'react'2import {3 View,4 Text,5 NavigationExperimental,6} from 'react-native'7const {8 CardStack: NavigationCardStack9} = NavigationExperimental10import Splash from '../screens/Splash/Splash'11import OAuthLogin from '../screens/Login/OAuthLogin'12import WelcomeScreen from '../screens/Login/WelcomeScreen'13import ChildAge from '../screens/Onboarding/ChildAge'14import ChildGender from '../screens/Onboarding/ChildGender'15import GearKind from '../screens/Onboarding/GearKind'16import LocationPrompt from '../screens/Onboarding/LocationPrompt'17import Location from '../screens/Onboarding/Location'18import TabContainer from '../containers/Tab'19import { SCENES } from '../constants/Scenes'20import { util, defineNextScene } from '../util'21export default class SplashNavigator extends Component {22 constructor (props) {23 super(props)24 }25 _handleNavigate (action, data, nextSceneHelper) {26 console.log('SplashNavigator _handleNavigate', action, data, nextSceneHelper);27 if(typeof action === 'symbol') {28 action = defineNextScene.splash(action, nextSceneHelper)29 }30 if(action == null) {31 console.warn('last scene')32 return false33 }34 switch (action && action.type) {35 case 'push':36 this.props.pushRoute(action.route, data)37 return true38 default:39 return false40 }41 }42 _renderScene (props) {43 // console.log('NavSplash111', props.scene, this.props)44 const { loginStore } = this.props45 const { route } = props.scene46 switch (route.key) {47 case SCENES.Splash.toString():48 return <Splash route={route} _handleNavigate={this._handleNavigate.bind(this)}/>49 case SCENES.OAuthLogin.toString():50 return <OAuthLogin route={route} _handleNavigate={this._handleNavigate.bind(this)}/>51 case SCENES.WelcomeScreen.toString():52 return <WelcomeScreen route={route} _handleNavigate={this._handleNavigate.bind(this)}/>53 case SCENES.ChildAge.toString():54 return <ChildAge route={route} _handleNavigate={this._handleNavigate.bind(this)}/>55 case SCENES.ChildGender.toString():56 return <ChildGender route={route} _handleNavigate={this._handleNavigate.bind(this)}/>57 case SCENES.GearKind.toString():58 return <GearKind route={route} _handleNavigate={this._handleNavigate.bind(this)}/>59 case SCENES.LocationPrompt.toString():60 return <LocationPrompt route={route} _handleNavigate={this._handleNavigate.bind(this)}/>61 case SCENES.Location.toString():62 return <Location route={route} _handleNavigate={this._handleNavigate.bind(this)}/>63 case SCENES.TabContainer.toString():64 return <TabContainer loginStore={loginStore}/>65 default:66 return null67 }68 }69 render(){70 return (71 <NavigationCardStack72 navigationState={this.props.navigationSplash}73 onNavigate={this._handleNavigate.bind(this)}74 renderScene={this._renderScene.bind(this)} />75 )76 }...

Full Screen

Full Screen

lightningNavigation.js

Source:lightningNavigation.js Github

copy

Full Screen

1import { LightningElement } from 'lwc';2import { NavigationMixin } from 'lightning/navigation';3export default class LightningNavigation extends NavigationMixin(LightningElement) {4 navigateCurrentTab(){5 this[NavigationMixin.Navigate]({6 type: 'standard__navItemPage',7 attributes: {8 apiName: "LWC", 9 }10 });11 }12 navigateToObjectHome(){13 this[NavigationMixin.Navigate]({14 type: 'standard__objectPage',15 attributes: {16 "objectApiName": "Contact",17 "actionName": "home" 18 }19 });20 }21 navigateToListView(){22 this[NavigationMixin.Navigate]({23 type: 'standard__objectPage',24 attributes: {25 "objectApiName": "Contact",26 "actionName": "list" 27 },28 state: {29 filterName: 'Recent'30 }31 });32 }33 navigateToNewRecord() {34 this[NavigationMixin.Navigate]({35 type: 'standard__objectPage',36 attributes: {37 objectApiName: 'Contact',38 actionName: 'new'39 }40 });41 }42 navigateToRecordView() {43 this[NavigationMixin.Navigate]({44 type: 'standard__recordPage',45 attributes: {46 recordId: "0030o00002dCDi7AAG",47 objectApiName: 'Contact', // objectApiName is optional48 actionName: 'view'49 }50 });51 }52 navigateToRecordEditPage() {53 // Opens the Account record modal54 // to view a particular record.55 this[NavigationMixin.Navigate]({56 type: 'standard__recordPage',57 attributes: {58 recordId: "0030o00002dCDi7AAG",59 objectApiName: 'Contact', // objectApiName is optional60 actionName: 'edit'61 }62 });63 }64 navigateToRelatedList() {65 this[NavigationMixin.Navigate]({66 type: 'standard__recordRelationshipPage',67 attributes: {68 recordId: '0010o00002Dw6eGAAR',69 objectApiName: 'Account',70 relationshipApiName: 'Contacts',71 actionName: 'view'72 }73 });74 }75 navigateToWebPage() {76 this[NavigationMixin.Navigate]({77 type: 'standard__webPage',78 attributes: {79 url: 'https://www.salesforce.com'80 }81 }) 82 }...

Full Screen

Full Screen

_index.js

Source:_index.js Github

copy

Full Screen

1"use strict";2let NavigationState = require('./NavigationState.js');3let ResultCode = require('./ResultCode.js');4let NavigateToPoseActionGoal = require('./NavigateToPoseActionGoal.js');5let NavigateToPoseGoal = require('./NavigateToPoseGoal.js');6let NavigateToPoseResult = require('./NavigateToPoseResult.js');7let NavigateToPoseAction = require('./NavigateToPoseAction.js');8let NavigateToPoseFeedback = require('./NavigateToPoseFeedback.js');9let NavigateToPoseActionFeedback = require('./NavigateToPoseActionFeedback.js');10let NavigateToPoseActionResult = require('./NavigateToPoseActionResult.js');11module.exports = {12 NavigationState: NavigationState,13 ResultCode: ResultCode,14 NavigateToPoseActionGoal: NavigateToPoseActionGoal,15 NavigateToPoseGoal: NavigateToPoseGoal,16 NavigateToPoseResult: NavigateToPoseResult,17 NavigateToPoseAction: NavigateToPoseAction,18 NavigateToPoseFeedback: NavigateToPoseFeedback,19 NavigateToPoseActionFeedback: NavigateToPoseActionFeedback,20 NavigateToPoseActionResult: NavigateToPoseActionResult,...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { navigate } from 'storybook-root';2navigate('/some/path');3import { navigate } from 'storybook-root';4navigate('/some/path');5import { navigate } from 'storybook-root';6navigate('/some/path');7MIT © [jameslnewell](

Full Screen

Using AI Code Generation

copy

Full Screen

1import { navigate } from '@storybook/router';2navigate('/story/components-button');3import { setQueryParams } from '@storybook/router';4setQueryParams({ foo: 'bar' });5import { clearQueryParams } from '@storybook/router';6clearQueryParams();7import { getQueryParam } from '@storybook/router';8const foo = getQueryParam('foo');9import { getQueryParams } from '@storybook/router';10const queryParams = getQueryParams();11import { getCurrentLocation } from '@storybook/router';12const location = getCurrentLocation();13import { getMatch } from '@storybook/router';14const match = getMatch();15import { toId } from '@storybook/router';16const id = toId('Components', 'Button');

Full Screen

Using AI Code Generation

copy

Full Screen

1import { navigate } from '@storybook/router';2const navigateTo = (path) => {3 navigate(path, { storyId: 'my-story' });4};5### `navigate(path, options)`6### `api.navigateUrl(url, options)`7### `api.navigate(options)`

Full Screen

Using AI Code Generation

copy

Full Screen

1import { navigate } from '@storybook/addon-links';2navigate('/some-path');3import { withLinks } from '@storybook/addon-links';4export default {5};6import { withQuery } from '@storybook/addon-links';7export default {8};9import { linkTo } from '@storybook/addon-links';10export default {11};12export const MyComponent = () => (13 <a href="#" onClick={linkTo('Button', 'Button with text')}>14);15import { linkTo } from '@storybook/addon-links';16export default {17};18export const MyComponent = () => (19 <a href="#" onClick={linkTo('Button', 'Button with text', { foo: 'bar' })}>20);

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