Skip to content

Commit 5ff8497

Browse files
authored
Merge pull request #111 from codeitcodes/dev
Dev
2 parents adc92ef + f2f4c1e commit 5ff8497

File tree

4 files changed

+85
-47
lines changed

4 files changed

+85
-47
lines changed

filebrowser.js

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ async function renderSidebarHTML() {
7676

7777
// show repo name in sidebar
7878
sidebarLogo.innerText = repoName;
79+
80+
// scroll to start of repo name
81+
sidebarLogo.scrollTo(0, 0);
82+
scrolledSidebarTitle();
7983

8084
// change header options
8185
header.classList.remove('out-of-repo');
@@ -163,9 +167,16 @@ async function renderSidebarHTML() {
163167
treeLoc[1] = '';
164168
treeLoc[2] = '';
165169
saveTreeLocLS(treeLoc);
166-
170+
171+
// change sidebar title
172+
sidebarLogo.innerText = 'Repositories';
173+
174+
// scroll to start of repo name
175+
sidebarLogo.scrollTo(0, 0);
176+
scrolledSidebarTitle();
177+
167178
renderSidebarHTML();
168-
179+
169180
return;
170181

171182
}
@@ -195,6 +206,10 @@ async function renderSidebarHTML() {
195206

196207
// show repo name in sidebar
197208
sidebarLogo.innerText = repoName;
209+
210+
// scroll to start of repo name
211+
sidebarLogo.scrollTo(0, 0);
212+
scrolledSidebarTitle();
198213

199214
// change header options
200215
header.classList.remove('out-of-repo');
@@ -316,8 +331,12 @@ async function renderSidebarHTML() {
316331

317332
}
318333

319-
// animate title
320-
if (sidebarLogo.scrollLeft > 0) titleAnimation = 'smooth';
334+
335+
// scroll to end of title
336+
sidebarLogo.scrollTo({
337+
left: sidebarLogo.scrollWidth - sidebarLogo.offsetLeft,
338+
behavior: 'smooth'
339+
});
321340

322341
} else if (repo != '') {
323342

@@ -333,31 +352,34 @@ async function renderSidebarHTML() {
333352
sidebarLogo.innerText = user + '/' + repoName;
334353

335354
}
355+
356+
// scroll to start of repo name
357+
sidebarLogo.scrollTo(0, 0);
358+
sidebarLogo.classList.add('notransition');
359+
360+
window.setTimeout(() => {
361+
sidebarLogo.classList.remove('notransition');
362+
}, 180);
363+
364+
scrolledSidebarTitle();
336365

337366
} else {
338367

339368
// show title
340369
sidebarLogo.innerText = 'Repositories';
341-
342-
}
343-
344-
// scroll to end of title
345-
346-
if (!titleAnimation) {
347-
370+
371+
// scroll to start of repo name
372+
sidebarLogo.scrollTo(0, 0);
348373
sidebarLogo.classList.add('notransition');
349-
374+
350375
window.setTimeout(() => {
351376
sidebarLogo.classList.remove('notransition');
352377
}, 180);
378+
379+
scrolledSidebarTitle();
353380

354381
}
355382

356-
sidebarTitle.children[1].scrollTo({
357-
left: sidebarLogo.scrollWidth - sidebarLogo.offsetLeft,
358-
behavior: titleAnimation
359-
});
360-
361383

362384
// if navigating in repository
363385
if (repo != '') {
@@ -693,6 +715,10 @@ function addHTMLItemListeners() {
693715

694716
// show repo name in sidebar
695717
sidebarLogo.innerText = repoLoc[1];
718+
719+
// scroll to start of repo name
720+
sidebarLogo.scrollTo(0, 0);
721+
scrolledSidebarTitle();
696722

697723
// change header options
698724
header.classList.remove('out-of-repo');
@@ -1413,8 +1439,10 @@ sidebarTitle.addEventListener('click', (e) => {
14131439
// show gradients on edges of sidebar title
14141440
// when scrolling long titles
14151441

1416-
sidebarLogo.addEventListener('scroll', () => {
1442+
sidebarLogo.addEventListener('scroll', scrolledSidebarTitle);
14171443

1444+
function scrolledSidebarTitle() {
1445+
14181446
if (sidebarLogo.scrollLeft > 0) {
14191447

14201448
sidebarLogo.classList.add('scrolled-start');
@@ -1435,8 +1463,8 @@ sidebarLogo.addEventListener('scroll', () => {
14351463
sidebarLogo.classList.remove('scrolled-end');
14361464

14371465
}
1438-
1439-
})
1466+
1467+
}
14401468

14411469

14421470
// if clicked on branch icon,

files.js

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -120,30 +120,34 @@ function onFileEclipsedInCache(oldSha, newSha, newFile) {
120120
// find the eclipsed file
121121
fileToUpdate = modifiedFiles[oldSha];
122122

123-
// update old file to new sha
124-
fileToUpdate.sha = newSha;
125-
126-
// update old file caret pos
127-
fileToUpdate.caretPos = [0, 0];
128-
129-
// set old file to eclipsed mode
130-
fileToUpdate.eclipsed = true;
131-
132-
// if file to update is selected
133-
if (selectedFile.sha === oldSha) {
134-
135-
// update its content
136-
// to the selected file contents
137-
fileToUpdate.content = selectedFile.content;
138-
139-
// update selected file to new sha
140-
selectedFile.sha = newSha;
123+
if (fileToUpdate) {
124+
125+
// update old file to new sha
126+
fileToUpdate.sha = newSha;
127+
128+
// update old file caret pos
129+
fileToUpdate.caretPos = [0, 0];
130+
131+
// set old file to eclipsed mode
132+
fileToUpdate.eclipsed = true;
133+
134+
// if file to update is selected
135+
if (selectedFile.sha === oldSha) {
136+
137+
// update its content
138+
// to the selected file contents
139+
fileToUpdate.content = selectedFile.content;
140+
141+
// update selected file to new sha
142+
selectedFile.sha = newSha;
143+
144+
// set selected file to eclipsed mode
145+
selectedFile.eclipsed = true;
146+
147+
updateSelectedFileLS();
148+
149+
}
141150

142-
// set selected file to eclipsed mode
143-
selectedFile.eclipsed = true;
144-
145-
updateSelectedFileLS();
146-
147151
}
148152

149153
} else {
@@ -153,8 +157,12 @@ function onFileEclipsedInCache(oldSha, newSha, newFile) {
153157
}
154158

155159

156-
// store the updated file under new sha as key
157-
modifiedFiles[newSha] = fileToUpdate;
160+
if (fileToUpdate) {
161+
162+
// store the updated file under new sha as key
163+
modifiedFiles[newSha] = fileToUpdate;
164+
165+
}
158166

159167

160168
// update modified files in local storage

full.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,6 @@ body.notransition .sidebar {
825825
padding: 12px 0;
826826
padding-left: 18px;
827827
margin-left: -18px;
828-
flex: 1;
829828
}
830829

831830
.sidebar .header .title-screen .title:hover {
@@ -852,7 +851,7 @@ body.notransition .sidebar {
852851
.sidebar .header .logo::after {
853852
content: '';
854853
position: absolute;
855-
right: 44px;
854+
right: 0;
856855
width: 28px;
857856
height: 20px;
858857
background: linear-gradient(270deg, #1a1c24, #1a1c2400);
@@ -888,6 +887,8 @@ body.notransition .sidebar {
888887
.sidebar .header .title .branch-icon {
889888
padding: 5px;
890889
opacity: .5;
890+
position: absolute;
891+
right: -26px;
891892
color: #828689;
892893
display: none;
893894
z-index: 1;

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,4 @@ <h2 class="color-1 weight-title-h font-title section__title center">A codeful of
241241
</body>
242242

243243
</html>
244+

0 commit comments

Comments
 (0)