|
59 | 59 | .pagination-num.active { |
60 | 60 | background-color: yellowgreen; |
61 | 61 | } |
62 | | - #progress-bar { |
63 | | - width: 600px; |
64 | | - height: 20px; |
65 | | - border-radius: 20px; |
66 | | - background-color: #e0e0e0; |
67 | | - overflow: hidden; |
68 | | - } |
69 | | - #progress-fill { |
70 | | - height: 100%; |
71 | | - width: 0%; /* 초기에는 0% 채워짐 */ |
72 | | - background-color: #4caf50; /* 채워지는 색 */ |
73 | | - transition: width 0.3s ease; /* 부드럽게 변화 */ |
74 | | - } |
75 | 62 | #scroll-progress-bar { |
76 | 63 | width: 600px; |
77 | 64 | height: 20px; |
|
103 | 90 | <button class="navigation-btn" id="next">Next</button> |
104 | 91 | </div> |
105 | 92 | <div id="pagination"></div> |
106 | | - <div id="progress-bar"> |
107 | | - <div id="progress-fill"></div> |
108 | | - </div> |
109 | 93 | <div id="scroll-progress-bar"> |
110 | 94 | <div id="scroll-progress-fill"></div> |
111 | 95 | </div> |
|
128 | 112 | const flicking = new Flicking(".flicking-viewport", { |
129 | 113 | renderOnlyVisible: true, |
130 | 114 | // circular: true |
| 115 | + // horizontal: false |
| 116 | + // align: 'center', |
| 117 | + defaultIndex: 2, |
131 | 118 | }); |
132 | 119 | const { connectFlickingReactiveAPI } = Flicking; |
133 | 120 | const reactiveObj = connectFlickingReactiveAPI(flicking); |
|
137 | 124 | totalPanelCount, |
138 | 125 | currentPanelIndex, |
139 | 126 | moveTo, |
| 127 | + progress, |
140 | 128 | } = reactiveObj; |
141 | 129 |
|
142 | 130 | // Navigation buttons |
|
204 | 192 | flicking.remove(0); |
205 | 193 | }); |
206 | 194 |
|
207 | | - // active panel을 지우는 경우 포커스가 가장 처음으로 돌아가는 현상이 있음. |
208 | 195 | removeLastButton.addEventListener("click", () => { |
209 | 196 | flicking.remove(flicking.panelCount - 1); |
210 | 197 | }); |
|
214 | 201 | }); |
215 | 202 |
|
216 | 203 | const paginationElement = document.getElementById("pagination"); |
217 | | - const progressFillElement = document.getElementById("progress-fill"); |
218 | 204 |
|
219 | 205 | const pageNums = Array.from({ length: totalPanelCount }, (_, i) => { |
220 | 206 | const div = document.createElement("div"); |
|
243 | 229 | const scrollProgressFillElement = document.getElementById( |
244 | 230 | "scroll-progress-fill" |
245 | 231 | ); |
| 232 | + scrollProgressFillElement.style.width = `${progress}%`; |
| 233 | + |
246 | 234 | reactiveObj.subscribe("progress", (nextValue) => { |
247 | 235 | scrollProgressFillElement.style.width = `${nextValue}%`; |
248 | 236 | }); |
|
0 commit comments