Skip to content

Commit ddcc705

Browse files
authored
Merge pull request #232 from codeitcodes/patch-2
2 parents 6491290 + 8894fd1 commit ddcc705

File tree

6 files changed

+86
-97
lines changed

6 files changed

+86
-97
lines changed

bottomfloat.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,25 @@ if (isMobile) {
115115
bottomWrapper.classList.remove('hidden');
116116

117117
});
118+
119+
120+
// update on screen resize
121+
122+
bottomWrapper.style.setProperty('--window-height', window.innerHeight + 'px');
123+
124+
bottomWrapper.lastHeight = 0;
125+
126+
window.addEventListener('resize', () => {
127+
128+
if (bottomWrapper.lastHeight === window.innerHeight) {
129+
return;
130+
}
131+
132+
bottomWrapper.lastHeight = window.innerHeight;
133+
134+
bottomWrapper.style.setProperty('--window-height', window.innerHeight + 'px');
135+
136+
});
118137

119138
}
120139

@@ -134,13 +153,13 @@ function checkBottomFloat() {
134153
bottomWrapper.classList.add('hidden');
135154

136155
// if scrolled to bottom of codeit
137-
if (cd.scrollTop >= (cd.scrollHeight - cd.offsetHeight)) {
156+
if (cd.scrollTop >= (cd.scrollHeight - cd.offsetHeight - 1)) {
138157

139158
// set timeout
140159
window.setTimeout(() => {
141160

142161
// if still on bottom of codeit
143-
if (cd.scrollTop >= (cd.scrollHeight - cd.offsetHeight)) {
162+
if (cd.scrollTop >= (cd.scrollHeight - cd.offsetHeight - 1)) {
144163

145164
// show bottom float
146165
bottomWrapper.classList.remove('hidden');

filebrowser.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2690,6 +2690,15 @@ learnAbout.addEventListener('click', () => {
26902690

26912691
});
26922692

2693+
// copy version when clicked
2694+
versionEl.addEventListener('click', () => {
2695+
2696+
copy(version).then(() => {
2697+
showMessage('Copied version!');
2698+
});
2699+
2700+
});
2701+
26932702
// share codeit on click of button
26942703
learnShare.addEventListener('click', () => {
26952704

@@ -2722,8 +2731,29 @@ learnClose.addEventListener('click', () => {
27222731
})
27232732

27242733

2734+
sidebar.trTimeout = null;
2735+
27252736
// toggle the sidebar
27262737
function toggleSidebar(open) {
2738+
2739+
if (sidebar.trTimeout) window.clearTimeout(sidebar.trTimeout);
2740+
2741+
if (body.classList.contains('notransition')) {
2742+
2743+
sidebar.classList.remove('transitioning');
2744+
2745+
} else {
2746+
2747+
sidebar.classList.add('transitioning');
2748+
2749+
sidebar.trTimeout = window.setTimeout(() => {
2750+
2751+
sidebar.classList.remove('transitioning');
2752+
2753+
}, 400);
2754+
2755+
}
2756+
27272757

27282758
if (open) {
27292759

@@ -2763,7 +2793,7 @@ function toggleSidebar(open) {
27632793
}
27642794

27652795
}
2766-
2796+
27672797
}
27682798

27692799

@@ -3039,7 +3069,7 @@ function setupEditor() {
30393069

30403070
// update on screen resize
30413071

3042-
let lastWidth = undefined;
3072+
let lastWidth;
30433073

30443074
window.addEventListener('resize', () => {
30453075

full.css

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ body cd-el {
5959

6060
.bottom-wrapper {
6161
position: fixed;
62-
bottom: env(safe-area-inset-bottom, 0px);
62+
bottom: 0;
6363
left: 0;
6464
right: 0;
6565
height: calc(45px + 56px + 45px);
@@ -81,29 +81,18 @@ body.notransition .bottom-wrapper {
8181
}
8282

8383
.bottom-wrapper.expanded {
84-
transform: translateY(calc(-100vh + 100% - env(safe-area-inset-top, 0px)));
84+
transform: translateY(calc(-1 * var(--window-height, 100vh) + 44px + env(safe-area-inset-top, 0px)));
8585
height: 44px;
8686
}
8787

88-
.bottom-wrapper.expanded.fromtop {
89-
top: env(safe-area-inset-top, 0px);
90-
bottom: auto;
91-
transform: none;
92-
transition: none;
93-
}
94-
95-
.bottom-wrapper.expanded.fromtop * {
96-
transition: none !important;
97-
}
98-
9988
.bottom-wrapper.notransition, .bottom-wrapper.notransition * {
10089
transition: none !important;
10190
}
10291

10392
.bottom-float {
10493
position: relative;
10594
margin: 45px 0;
106-
width: calc(100% - 45px - env(safe-area-inset-left));
95+
width: calc(100% - 45px);
10796
max-width: 600px;
10897
display: flex;
10998
align-items: center;
@@ -145,6 +134,7 @@ body.notransition .bottom-wrapper {
145134

146135
.bottom-wrapper.expanded .bottom-float .sidebar-open {
147136
padding: 11px 16px;
137+
background: transparent;
148138
}
149139

150140
.bottom-float .sidebar-open:active {
@@ -737,7 +727,6 @@ body.expanded .sidebar-toggle svg .left {
737727
padding-left: env(safe-area-inset-left);
738728
padding-right: 1px;
739729
box-sizing: border-box;
740-
will-change: transform;
741730
z-index: 998;
742731
}
743732

@@ -755,6 +744,10 @@ body.expanded .sidebar-toggle svg .left {
755744
}
756745
*/
757746

747+
.sidebar.transitioning {
748+
will-change: transform;
749+
}
750+
758751
body.expanded .sidebar {
759752
transform: translateX(calc(100% - 1px));
760753
pointer-events: auto;
@@ -795,7 +788,7 @@ body.notransition .sidebar {
795788

796789
.sidebar .loader {
797790
position: sticky;
798-
top: 0;
791+
top: 0.5px;
799792
left: 0;
800793
height: 2px;
801794
width: var(--sidebar-width);
@@ -917,7 +910,7 @@ body.notransition .sidebar {
917910
.sidebar .header .logo::after {
918911
content: '';
919912
position: absolute;
920-
right: 0;
913+
right: -0.5px;
921914
width: 28px;
922915
height: 20px;
923916
background: linear-gradient(270deg, #1a1c24, #1a1c2400);
@@ -930,7 +923,7 @@ body.notransition .sidebar {
930923
.sidebar .header .logo::before {
931924
right: auto;
932925
background: linear-gradient(90deg, #1a1c24, #1a1c2400);
933-
left: 42px;
926+
left: 41.5px;
934927
}
935928

936929
.sidebar .header .logo::after {
@@ -1437,6 +1430,12 @@ body:not(.mobile) .sidebar .header .title .branch-icon:active {
14371430
background: hsl(228deg 59% 6% / 50%);
14381431
}
14391432

1433+
@media screen and (orientation: landscape) {
1434+
body.mobile .sidebar .picture-wrapper {
1435+
display: none;
1436+
}
1437+
}
1438+
14401439
.sidebar .intro {
14411440
position: absolute;
14421441
width: calc(100% - 1px);
@@ -1451,6 +1450,10 @@ body:not(.mobile) .sidebar .header .title .branch-icon:active {
14511450
padding-left: 10px;
14521451
}
14531452

1453+
body.mobile .sidebar .intro {
1454+
margin-left: calc(-1 * env(safe-area-inset-left, 0px));
1455+
}
1456+
14541457
.sidebar .files .intro {
14551458
height: calc(100% - 74px);
14561459
margin-top: -11px;
@@ -1610,11 +1613,6 @@ body.mobile .sidebar .button {
16101613
align-items: center;
16111614
}
16121615

1613-
.sidebar .learn-wrapper .version {
1614-
user-select: text;
1615-
-webkit-user-select: text;
1616-
}
1617-
16181616
.sidebar .learn-wrapper .logout {
16191617
display: none;
16201618
}
@@ -2384,6 +2382,10 @@ body:not(.mobile) .sidebar .header .logo::-webkit-scrollbar {
23842382
height: 10px;
23852383
}
23862384

2385+
body.mobile .sidebar .header .logo::-webkit-scrollbar {
2386+
opacity: 0;
2387+
}
2388+
23872389
body:not(.mobile) .sidebar .header .logo::-webkit-scrollbar-track {
23882390
background: transparent;
23892391
box-shadow: none;
@@ -2581,3 +2583,4 @@ html, body {
25812583
}
25822584

25832585
}
2586+

lib/plugins/codeit-autocomplete.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ CSSProps.push('border');
3030
CSSProps.push('flex');
3131
CSSProps.push('grid');
3232
CSSProps.push('gap');
33+
CSSProps.push('background');
3334
CSSProps.push('-webkit-user-select');
3435

3536
const maxChar = 0;//4;

live-view/live-view.js

Lines changed: 5 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ async function setupLiveView() {
3838
// expand bottom float
3939
bottomWrapper.classList.add('expanded');
4040

41-
// fix bottom float on safari
42-
if (isSafari) bottomWrapper.classList.add('fromtop');
43-
4441
// restore transition on next frame
4542
onNextFrame(() => {
4643
bottomWrapper.classList.remove('notransition');
@@ -175,9 +172,6 @@ async function setupLiveView() {
175172
// close bottom float
176173
bottomWrapper.classList.remove('expanded');
177174

178-
// fix bottom float on safari
179-
if (isSafari) bottomWrapper.classList.remove('fromtop');
180-
181175
// restore transition on next frame
182176
onNextFrame(() => {
183177
bottomWrapper.classList.remove('notransition');
@@ -426,31 +420,8 @@ function addBottomSwipeListener() {
426420
e.preventDefault();
427421
e.stopPropagation();
428422

429-
// fix bottom float on safari
430-
if (isSafari) {
431-
432-
bottomWrapper.classList.remove('fromtop');
433-
bottomWrapper.classList.add('notransition');
434-
435-
onNextFrame(() => {
436-
437-
bottomWrapper.classList.remove('notransition');
438-
439-
onNextFrame(() => {
440-
441-
// retract bottom float
442-
bottomWrapper.classList.remove('expanded');
443-
444-
});
445-
446-
});
447-
448-
} else {
449-
450-
// retract bottom float
451-
bottomWrapper.classList.remove('expanded');
452-
453-
}
423+
// retract bottom float
424+
bottomWrapper.classList.remove('expanded');
454425

455426
toggleLiveView(selectedFile);
456427

@@ -518,18 +489,6 @@ function addBottomSwipeListener() {
518489
// expand bottom float
519490
bottomWrapper.classList.add('expanded');
520491

521-
// fix bottom float on safari
522-
// when finished transitioning
523-
if (isSafari) {
524-
525-
window.setTimeout(() => {
526-
527-
bottomWrapper.classList.add('fromtop');
528-
529-
}, 400);
530-
531-
}
532-
533492
// if live view is closed
534493
if (!liveViewToggle) toggleLiveView(selectedFile);
535494

@@ -541,31 +500,8 @@ function addBottomSwipeListener() {
541500
if (swiped && bottomWrapper.classList.contains('expanded')
542501
&& !bottomFloat.classList.contains('file-open')) {
543502

544-
// fix bottom float on safari
545-
if (isSafari) {
546-
547-
bottomWrapper.classList.remove('fromtop');
548-
bottomWrapper.classList.add('notransition');
549-
550-
onNextFrame(() => {
551-
552-
bottomWrapper.classList.remove('notransition');
553-
554-
onNextFrame(() => {
555-
556-
// retract bottom float
557-
bottomWrapper.classList.remove('expanded');
558-
559-
});
560-
561-
});
562-
563-
} else {
564-
565-
// retract bottom float
566-
bottomWrapper.classList.remove('expanded');
567-
568-
}
503+
// retract bottom float
504+
bottomWrapper.classList.remove('expanded');
569505

570506
// if live view is open
571507
if (liveViewToggle) toggleLiveView(selectedFile);
@@ -1146,7 +1082,7 @@ async function renderLiveViewHTML(file) {
11461082
// render live view for Markdown files
11471083
async function renderLiveViewMarkdown(file) {
11481084

1149-
liveView.innerHTML = '<iframe srcdoc="<!DOCTYPE html><html><head></head><body></body></html>" name="Live view" title="Live view" style="background: hsl(228deg 16% 12%);" class="live-frame" loading="lazy" scrolling="yes" frameborder="0"></iframe>';
1085+
liveView.innerHTML = '<iframe srcdoc="<!DOCTYPE html><html><head></head><body ontouchstart></body></html>" name="Live view" title="Live view" style="background: hsl(228deg 16% 12%);" class="live-frame" loading="lazy" scrolling="yes" frameborder="0"></iframe>';
11501086

11511087
const liveFrame = liveView.querySelector('.live-frame');
11521088

worker/client-channel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
// update worker name when updating worker
7-
const WORKER_NAME = 'codeit-worker-v586';
7+
const WORKER_NAME = 'codeit-worker-v599';
88

99

1010
// internal paths

0 commit comments

Comments
 (0)