File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ Get configuration parameters and initialize the web page;
15
15
function init ( config ) {
16
16
addEventListeners ( config ) ;
17
17
setBorders ( config . width , config . height ) ;
18
+ addProgress ( config ) ;
18
19
}
19
20
20
21
/*
@@ -67,3 +68,35 @@ function handleOnkeydown(event) {
67
68
// No default
68
69
}
69
70
}
71
+
72
+ /*
73
+ Add progress to each slide based on config
74
+ */
75
+
76
+ function addProgress ( config ) {
77
+ if ( ! config . progress || config . progress === 'none' ) {
78
+ return ;
79
+ }
80
+
81
+ const articles = [ ...document . getElementsByTagName ( 'article' ) ] ;
82
+
83
+ if ( config . progress === 'line' ) {
84
+ articles . forEach ( ( article , index ) => {
85
+ const line = document . createElement ( 'div' ) ;
86
+ line . classList . add ( "progress-line" ) ;
87
+ article . appendChild ( line ) ;
88
+
89
+ line . style . backgroundColor = 'var(--primary-color)' ;
90
+
91
+ line . style . height = '3px' ;
92
+ line . style . position = 'absolute' ;
93
+
94
+ line . style . bottom = '0' ;
95
+ line . style . left = '0' ;
96
+
97
+ const normIndex = index / ( articles . length - 1 ) ;
98
+
99
+ line . style . width = `${ config . width * normIndex } px` ;
100
+ } )
101
+ }
102
+ }
You can’t perform that action at this time.
0 commit comments