How to use Timeline method in tracetest

Best JavaScript code snippet using tracetest

horizontal-timeline.js

Source:horizontal-timeline.js Github

copy

Full Screen

...11 /*12 ** All functions to be called on $(window).load() should be in this function13 */14 function qodeOnDocumentReady() {15 qodeInitHorizontalTimeline();16 }17 18 function qodeInitHorizontalTimeline() {19 var timelines = $('.qode-horizontal-timeline');20 21 var eventsMinDistance = 120;22 if(qode.windowWidth > 680 && qode.windowWidth <= 1024) {23 eventsMinDistance = 60;24 } else if (qode.windowWidth < 680) {25 eventsMinDistance = 105;26 }27 28 if(timelines.length) {29 timelines.each(function() {30 var timeline = $(this),31 timelineComponents = {};32 33 //cache timeline components34 timelineComponents['timelineWrapper'] = timeline.find('.qode-events-wrapper');35 timelineComponents['eventsWrapper'] = timelineComponents['timelineWrapper'].children('.qode-events');36 timelineComponents['fillingLine'] = timelineComponents['eventsWrapper'].children('.qode-filling-line');37 timelineComponents['timelineEvents'] = timelineComponents['eventsWrapper'].find('a');38 timelineComponents['timelineDates'] = parseDate(timelineComponents['timelineEvents']);39 timelineComponents['eventsMinLapse'] = minLapse(timelineComponents['timelineDates']);40 timelineComponents['timelineNavigation'] = timeline.find('.qode-timeline-navigation');41 timelineComponents['eventsContent'] = timeline.children('.qode-events-content');42 43 timelineComponents['eventsWrapper'].find('ol li:first-child a').addClass('selected');44 timelineComponents['eventsContent'].find('ol li:first-child').addClass('selected');45 46 //assign a left postion to the single events along the timeline47 setDatePosition(timelineComponents, eventsMinDistance, timeline);48 //assign a width to the timeline49 var timelineTotWidth = setTimelineWidth(timelineComponents, eventsMinDistance, timeline);50 //the timeline has been initialize - show it51 timeline.addClass('loaded');52 53 //detect click on the next arrow54 timelineComponents['timelineNavigation'].on('click', '.qode-next', function(event){55 event.preventDefault();56 updateSlide(timelineComponents, timelineTotWidth, 'next');57 });58 //detect click on the prev arrow59 timelineComponents['timelineNavigation'].on('click', '.qode-prev', function(event){60 event.preventDefault();61 updateSlide(timelineComponents, timelineTotWidth, 'prev');62 });63 //detect click on the a single event - show new event content64 timelineComponents['eventsWrapper'].on('click', 'a', function(event){65 event.preventDefault();66 timelineComponents['timelineEvents'].removeClass('selected');67 $(this).addClass('selected');68 updateOlderEvents($(this));69 updateFilling($(this), timelineComponents['fillingLine'], timelineTotWidth);70 updateVisibleContent($(this), timelineComponents['eventsContent']);71 });72 73 //on swipe, show next/prev event content74 timelineComponents['eventsContent'].on('swipeleft', function(){75 var mq = checkMQ();76 ( mq == 'mobile' ) && showNewContent(timelineComponents, timelineTotWidth, 'next');77 });78 timelineComponents['eventsContent'].on('swiperight', function(){79 var mq = checkMQ();80 ( mq == 'mobile' ) && showNewContent(timelineComponents, timelineTotWidth, 'prev');81 });82 83 //keyboard navigation84 $(document).keyup(function(event){85 if(event.which === '37' && elementInViewport(timeline.get(0)) ) {86 showNewContent(timelineComponents, timelineTotWidth, 'prev');87 } else if( event.which === '39' && elementInViewport(timeline.get(0))) {88 showNewContent(timelineComponents, timelineTotWidth, 'next');89 }90 });91 });92 }93 94 function updateSlide(timelineComponents, timelineTotWidth, string) {95 //retrieve translateX value of timelineComponents['eventsWrapper']96 var translateValue = getTranslateValue(timelineComponents['eventsWrapper']),97 wrapperWidth = Number(timelineComponents['timelineWrapper'].css('width').replace('px', ''));98 //translate the timeline to the left('next')/right('prev')99 (string === 'next')100 ? translateTimeline(timelineComponents, translateValue - wrapperWidth + eventsMinDistance, wrapperWidth - timelineTotWidth)101 : translateTimeline(timelineComponents, translateValue + wrapperWidth - eventsMinDistance);102 }103 104 function showNewContent(timelineComponents, timelineTotWidth, string) {105 //go from one event to the next/previous one106 var visibleContent = timelineComponents['eventsContent'].find('.selected'),107 newContent = ( string === 'next' ) ? visibleContent.next() : visibleContent.prev();108 109 if ( newContent.length > 0 ) { //if there's a next/prev event - show it110 var selectedDate = timelineComponents['eventsWrapper'].find('.selected'),111 newEvent = ( string === 'next' ) ? selectedDate.parent('li').next('li').children('a') : selectedDate.parent('li').prev('li').children('a');112 113 updateFilling(newEvent, timelineComponents['fillingLine'], timelineTotWidth);114 updateVisibleContent(newEvent, timelineComponents['eventsContent']);115 newEvent.addClass('selected');116 selectedDate.removeClass('selected');117 updateOlderEvents(newEvent);118 updateTimelinePosition(string, newEvent, timelineComponents);119 }120 }121 122 function updateTimelinePosition(string, event, timelineComponents) {123 //translate timeline to the left/right according to the position of the selected event124 var eventStyle = window.getComputedStyle(event.get(0), null),125 eventLeft = Number(eventStyle.getPropertyValue("left").replace('px', '')),126 timelineWidth = Number(timelineComponents['timelineWrapper'].css('width').replace('px', '')),127 timelineTotWidth = Number(timelineComponents['eventsWrapper'].css('width').replace('px', ''));128 var timelineTranslate = getTranslateValue(timelineComponents['eventsWrapper']);129 130 if( (string === 'next' && eventLeft > timelineWidth - timelineTranslate) || (string == 'prev' && eventLeft < - timelineTranslate) ) {131 translateTimeline(timelineComponents, - eventLeft + timelineWidth/2, timelineWidth - timelineTotWidth);132 }133 }134 135 function translateTimeline(timelineComponents, value, totWidth) {136 var eventsWrapper = timelineComponents['eventsWrapper'].get(0);137 value = (value > 0) ? 0 : value; //only negative translate value138 value = ( typeof totWidth !== 'undefined' && value < totWidth ) ? totWidth : value; //do not translate more than timeline width139 setTransformValue(eventsWrapper, 'translateX', value+'px');140 //update navigation arrows visibility141 (value === 0 ) ? timelineComponents['timelineNavigation'].find('.qode-prev').addClass('inactive') : timelineComponents['timelineNavigation'].find('.qode-prev').removeClass('inactive');142 (value === totWidth ) ? timelineComponents['timelineNavigation'].find('.qode-next').addClass('inactive') : timelineComponents['timelineNavigation'].find('.qode-next').removeClass('inactive');143 }144 145 function disableTranslateTimeline(timelineComponents) {146 timelineComponents['timelineNavigation'].find('.qode-prev').addClass('inactive');147 timelineComponents['timelineNavigation'].find('.qode-next').addClass('inactive');148 }149 150 function updateFilling(selectedEvent, filling, totWidth) {151 //change .filling-line length according to the selected event152 var eventStyle = window.getComputedStyle(selectedEvent.get(0), null),153 eventLeft = eventStyle.getPropertyValue("left"),154 eventWidth = eventStyle.getPropertyValue("width");155 eventLeft = Number(eventLeft.replace('px', '')) + Number(eventWidth.replace('px', ''))/2;156 var scaleValue = eventLeft/totWidth;157 setTransformValue(filling.get(0), 'scaleX', scaleValue);158 }159 160 function setDatePosition(timelineComponents, min, timeline) {161 var shorten = false;162 for (var i = 0; i < timelineComponents['timelineDates'].length; i++) {163 var distance = daydiff(timelineComponents['timelineDates'][0], timelineComponents['timelineDates'][i]),164 distanceNorm = Math.round(distance/timelineComponents['eventsMinLapse']) + 1;165 /* 24 is width of circles placed in link :after element */166 timelineComponents['timelineEvents'].eq(i).css('left', distanceNorm*min-24+'px');167 /* 80 is width of 2*40 margins on qode-events-wrapper */168 if(distanceNorm*min < timeline.outerWidth() - 80) {169 shorten = true;170 }171 else {172 shorten = false;173 }174 }175 if(shorten) {176 disableTranslateTimeline(timelineComponents);177 /* 80 is width of 2*40 margins on qode-events-wrapper, 24 is width of circles placed in link :after element */178 var minDistance = (timeline.outerWidth() - 80 - (timelineComponents['timelineDates'].length - 1) * 24) / (timelineComponents['timelineDates'].length + 1);179 for (var i = 0; i < timelineComponents['timelineDates'].length; i++) {180 timelineComponents['timelineEvents'].eq(i).css('left', (i+1)*minDistance+'px');181 }182 }183 }184 185 function setTimelineWidth(timelineComponents, width, timeline) {186 var timeSpan = daydiff(timelineComponents['timelineDates'][0], timelineComponents['timelineDates'][timelineComponents['timelineDates'].length-1]),187 timeSpanNorm = timeSpan/timelineComponents['eventsMinLapse'],188 timeSpanNorm = Math.round(timeSpanNorm) + 2,189 totalWidth = timeSpanNorm*width;190 /* 80 is width of 2*40 margins on qode-events-wrapper */...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const tracetest = require('tracetest');2tracetest.timeline('test');3const tracetest = require('tracetest');4tracetest.timeline('test');5const tracetest = require('tracetest');6tracetest.timeline('test');7const tracetest = require('tracetest');8tracetest.timeline('test');9const tracetest = require('tracetest');10tracetest.timeline('test');11const tracetest = require('tracetest');12tracetest.timeline('test');13const tracetest = require('tracetest');14tracetest.timeline('test');15const tracetest = require('tracetest');16tracetest.timeline('test');17const tracetest = require('tracetest');18tracetest.timeline('test');19const tracetest = require('tracetest');20tracetest.timeline('test');21const tracetest = require('tracetest');22tracetest.timeline('test');23const tracetest = require('tracetest');24tracetest.timeline('test');25const tracetest = require('tracetest');26tracetest.timeline('test');27const tracetest = require('tracetest');28tracetest.timeline('test');29const tracetest = require('trac

Full Screen

Using AI Code Generation

copy

Full Screen

1var Timeline = require('tracetest.js');2var timeline = new Timeline();3timeline.on('tick', function() {4 console.log('woohoo!');5});6timeline.start();7var EventEmitter = require('events').EventEmitter;8var util = require('util');9function Timeline() {10 EventEmitter.call(this);11}12util.inherits(Timeline, EventEmitter);13Timeline.prototype.start = function() {14 setInterval(function() {15 this.emit('tick');16 }.bind(this), 1000);17};18module.exports = Timeline;19var EventEmitter = require('events').EventEmitter;20var util = require('util');21function Timeline() {22 EventEmitter.call(this);23}24util.inherits(Timeline, EventEmitter);25Timeline.prototype.start = function() {26 setInterval(function() {27 this.emit('tick');28 }.bind(this), 1000);29};30var timeline = new Timeline();31timeline.on('tick', function() {32 console.log('woohoo!');33});34timeline.start();35var Timeline = require('./tracetest.js');36var timeline = new Timeline();37timeline.on('tick', function() {38 console.log('woohoo!');39});40timeline.start();41var EventEmitter = require('events').EventEmitter;42var util = require('util');43function Timeline() {44 EventEmitter.call(this);45}46util.inherits(Timeline, EventEmitter);47Timeline.prototype.start = function() {48 setInterval(function() {49 this.emit('tick');50 }.bind(this), 1000);51};52module.exports = Timeline;

Full Screen

Using AI Code Generation

copy

Full Screen

1var tracetest = require('./tracetest.js');2var timeline = tracetest.timeline;3timeline('test', function() {4 console.log('test');5});6var timeline = function(name, callback) {7 console.log(name);8 callback();9}10exports.timeline = timeline;

Full Screen

Using AI Code Generation

copy

Full Screen

1var trace = require('trace');2var traceTest = require('tracetest');3traceTest.traceTimeline('testTimeline', 'test message');4traceTest.traceTimeline('testTimeline', 'test message2');5traceTest.traceTimeline('testTimeline', 'test message3');6var trace = require('trace');7var traceTest = require('tracetest');8traceTest.traceTimeline('testTimeline', 'test message4');9traceTest.traceTimeline('testTimeline', 'test message5');10traceTest.traceTimeline('testTimeline', 'test message6');11var trace = require('trace');12var traceTest = require('tracetest');13traceTest.traceTimeline('testTimeline', 'test message7');14traceTest.traceTimeline('testTimeline', 'test message8');15traceTest.traceTimeline('testTimeline', 'test message9');16var trace = require('trace');17var traceTest = require('tracetest');18traceTest.traceTimeline('testTimeline', 'test message10');19traceTest.traceTimeline('testTimeline', 'test message11');20traceTest.traceTimeline('testTimeline', 'test message12');21var trace = require('trace');22var traceTest = require('tracetest');23traceTest.traceTimeline('testTimeline', 'test message13');24traceTest.traceTimeline('testTimeline', 'test message14');25traceTest.traceTimeline('testTimeline', 'test message15');26var trace = require('trace');27var traceTest = require('tracetest');28traceTest.traceTimeline('testTimeline', 'test message16');29traceTest.traceTimeline('testTimeline', 'test message17');30traceTest.traceTimeline('testTimeline', 'test message18');31var trace = require('trace');32var traceTest = require('tracetest');33traceTest.traceTimeline('testTimeline', 'test message19');34traceTest.traceTimeline('testTimeline', 'test message20');35traceTest.traceTimeline('testTimeline', 'test message21');

Full Screen

Using AI Code Generation

copy

Full Screen

1var trace = require('./tracetest.js');2var timeline = trace.timeline();3timeline.start();4timeline.stop();5timeline.report();6The following code shows how to use the timeline.start() and timeline.stop() methods:7var trace = require('./tracetest.js');8var timeline = trace.timeline();9timeline.start();10timeline.stop();11timeline.report();12The following code shows how to use the timeline.start() and timeline.stop() methods:13var trace = require('./tracetest.js');14var timeline = trace.timeline();15timeline.start();16timeline.stop();17timeline.report();18The following code shows how to use the timeline.start() and timeline.stop() methods:

Full Screen

Using AI Code Generation

copy

Full Screen

1var trace = require('./tracetest.js');2var timeline = trace.timeline;3timeline('start');4timeline('end');5timeline('done');6var trace = require('./tracetest.js');7var timeline = trace.timeline;8timeline('start');9timeline('end');10timeline('done');11var trace = require('./tracetest.js');12var timeline = trace.timeline;13timeline('start');14timeline('end');15timeline('done');16var trace = require('./tracetest.js');17var timeline = trace.timeline;18timeline('start');19timeline('end');20timeline('done');

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 tracetest 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