
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
@csiro-geoanalytics/raven-sticky-sidebar
Advanced tools
An Angular component for making sidebars that stick in place while content around them scrolls as usual.
An Angular component for making sidebars that stick in place while content around them scrolls as usual.
position:sticky
for better performanceInstall into your Angular project using NPM.
npm install raven-sticky-sidebar --save
Import the StickySidebarModule into your module.
import { StickySidebarModule } from 'raven-sticky-sidebar';
@NgModule({
imports: [
StickySidebarModule,
// ...
],
// ...
})
export class AppModule { }
Add a <raven-sticky-sidebar> element to your template, and use floats, flexbox, or grid to position the sidebar.
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: `
<style>
.wrapper {
display: grid;
grid-template-columns: 1fr 3fr;
grid-gap: 1rem;
}
</style>
<div class="wrapper">
<raven-sticky-sidebar>
<aside>Sidebar content...</aside>
</raven-sticky-sidebar>
<article>
Main content that scrolls...
</article>
</div>
`,
styles: []
})
export class AppComponent { }
Option | Type | Description | Default Value |
---|---|---|---|
topOffset | number | Space to add to the top while sidebar is stuck (px). | 0 |
container | string | A CSS selector string that points to the parent element. | "" |
Only add the container attribute if the sidebar is expected to stick within a parent element that has a limited height with its own scroll bars.
The primary reason for needing a bottom offset is when the sidebar is larger than the viewport, causing the bottom of the sidebar content to butt up against the bottom of the viewport.
This can be easily fixed by adding some bottom padding to the last element in the sidebar. You may also need to adjust how you add your background to prevent the background from showing below the last element (adding padding to a wrapper element can help in those cases).
Try creating a new Angular project with the bare minimum code necessary to make use of raven-sticky-sidebar. Gradually make changes to reproduce your issue in the bare environment.
Sometimes, when content in a sidebar is changed, it can cause problems with the initial calculations that were made. However, you can recalculate using the sidebar component’s reset()
method.
import { Component, ViewChild } from '@angular/core';
@Component({
selector: 'app-root',
template: `
<style>/* ... */</style>
<raven-sticky-sidebar #sidebar>
<!-- ... -->
</raven-sticky-sidebar>
`
})
export class AppComponent {
@ViewChild('sidebar')
sidebar: StickySidebarComponent;
someFuncThatUpdatesContent() {
// Update content in sidebar
// ...
// Reset sidebar
this.sidebar.reset()
}
}
Internet Explorer does not support position:sticky and is not compatible with raven-sticky-sidebar. Most other major browsers have support (including Edge).
To contribute to the development of this component, clone its repository and run npm install
. Then run ng serve -o
to start a development server and to open a sample page in your browser.
MIT license.
FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.