Skip to content

Commit

Permalink
Homepage scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
radogado committed May 6, 2023
1 parent d6b5e03 commit b6d3c3d
Show file tree
Hide file tree
Showing 19 changed files with 208 additions and 77 deletions.
1 change: 1 addition & 0 deletions components/button/button.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/button/button.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions components/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ button.n-btn,
a.n-btn[href],
.n-type a.n-btn[href] {
font-size: inherit;
text-align: initial;
line-height: var(--nui-line-height);
min-height: var(--nui-line-height-em);
text-decoration: none;
Expand Down
2 changes: 1 addition & 1 deletion components/parallax/parallax.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
let updateParallax = () => {
document.querySelectorAll(".n-parallax").forEach((el) => {
let parent = el.parentElement;
let scroll_offset = parent.scrollHeight > parent.offsetHeight ? Math.abs(parent.getBoundingClientRect().y) : document.body.scrollTop || document.documentElement.scrollTop;
let scroll_offset = parent.scrollHeight > parent.offsetHeight ? parent.getBoundingClientRect().y : document.body.scrollTop || document.documentElement.scrollTop;
el.style.setProperty("--scrollparallax", scroll_offset * parallaxSpeed);
});
};
Expand Down
65 changes: 59 additions & 6 deletions css/guide.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion css/guide.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 70 additions & 11 deletions css/guide.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ html {
// padding: 0;
// overflow: hidden; // Safari bug when zoomed in
// scroll-behavior: smooth;
height: 100%;
}

body {
Expand All @@ -57,7 +58,7 @@ body {
padding: 0;
// overflow: hidden;
// background: darkcyan;
// height: 100%;
height: 100%;
line-height: 1.333;
color: white;
}
Expand Down Expand Up @@ -100,7 +101,7 @@ li pre {
// aspect-ratio: 2;
}

.demo .n-carousel__content .n-carousel:not(.n-carousel--lightbox) > .n-carousel__content > * {
.demo .n-carousel:not(.n-carousel--lightbox) > .n-carousel__content > * {
color: var(--nui-input-color);
background: var(--nui-input-bg);
}
Expand Down Expand Up @@ -166,7 +167,7 @@ html {
--max-height: 100%;
}

max-width: 1366.666px;
// max-width: 1366.666px;

> .n-carousel__content {
> * {
Expand Down Expand Up @@ -368,11 +369,15 @@ html:not(.can-touch) nav li li[aria-haspopup]:hover {
--nui-control-active-color: #bc8453;
}

aside nav {
--nui-control-color: lightgrey;
--nui-control-active-color: #bc8453;
}
}

.n-scheme-auto {
@media (prefers-color-scheme: dark) {
.demo.n-carousel.n-carousel--tabs > .n-carousel__index {
aside nav {
--nui-control-color: lightgrey;
--nui-control-active-color: #bc8453;
}
Expand All @@ -385,10 +390,9 @@ html:not(.can-touch) nav li li[aria-haspopup]:hover {
mask: linear-gradient(red, red);
}

.n-type .demo {
.section-title {
margin-top: -0.4rem;
}

.n-type .demo .section-title {
margin-top: 0.5rem;
}

// iPad exit full screen bug
Expand Down Expand Up @@ -417,6 +421,13 @@ _:future,
margin-inline-start: calc(-1 * var(--nui-line-height-em)/2);
width: calc(100% + var(--nui-line-height-em));
}

.n-type .demo {
.section-title {
margin-top: -0.4rem;
}
}

}

aside {
Expand All @@ -429,14 +440,18 @@ aside {
nav {
white-space: nowrap;
overflow: auto;
padding: 1em;
padding: .667em;
display: flex;
gap: 1em;
box-shadow: 0 0 0.333em 0px #00000066;

a {
font-weight: 600;
font-weight: 500;
text-decoration: none;

span {
color: var(--nui-color);
}
}

a:first-of-type {
Expand All @@ -447,15 +462,59 @@ aside {
webkit-mask-repeat: no-repeat;
flex-shrink: 0;
width: 5em;

}

[href="#home"] span {
opacity: 0;
}

a[href][aria-current] {
color: var(--nui-control-active-color, #00f);

&:first-of-type {
background: var(--nui-control-active-color);
}
}

}
}

section {
padding-top: 3em;
min-height: calc(100vh - 3em);
min-height: calc(100dvh - 3em);

&:not(:last-of-type) {
padding-bottom: 2em;
border-bottom: 2px solid;
margin-bottom: 2em;
}
}

main {
min-width: 0;
height: 100%;
overflow: auto;
}

@media (min-width: 600px) {
section {
padding-top: 0;
}

body {
display: flex;
max-width: 1366.666px;
}

aside nav {
position: sticky;
top: 0;
flex-direction: column;
max-height: calc(100vh - 2em);
max-height: calc(100dvh - 2em);
box-shadow: none;
padding: 1em;
}
}
2 changes: 1 addition & 1 deletion dist/niui.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/niui.min.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/niui.min.css.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14353
14312
2 changes: 1 addition & 1 deletion dist/niui.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/niui.min.js.map

Large diffs are not rendered by default.

23 changes: 20 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3957,9 +3957,26 @@ <h2 class="section-title">Theme</h2>
})
})
});
window.addEventListener('load', e => {
document.querySelector('html').style.scrollBehavior = 'smooth';
});
document.querySelector(location.hash)?.scrollIntoView();
// window.addEventListener('load', e => {
document.querySelector('main').style.scrollBehavior = 'smooth';
document.querySelector('main').click();
// });

const inView = target => {
const interSecObs = new IntersectionObserver(entries => {
entries.forEach(entry => {
let slide = entry.target;
});
}, {
threshold: .75,
root: target.parentElement
});
interSecObs.observe(target);
console.log('intersection observing ', target)
};

document.querySelectorAll('main > section').forEach(inView);
</script>
</body>

Expand Down
Loading

0 comments on commit b6d3c3d

Please sign in to comment.