mirror of
https://github.com/rio-labs/rio.git
synced 2026-01-05 20:59:46 -06:00
fix browser not scrolling to ScrollTargets
This commit is contained in:
@@ -37,7 +37,7 @@ import { PopupComponent } from './components/popup';
|
||||
import { ProgressBarComponent } from './components/progressBar';
|
||||
import { ProgressCircleComponent } from './components/progressCircle';
|
||||
import { RectangleComponent } from './components/rectangle';
|
||||
import { reprElement } from './utils';
|
||||
import { reprElement, scrollToUrlFragment } from './utils';
|
||||
import { RevealerComponent } from './components/revealer';
|
||||
import { ScrollContainerComponent } from './components/scrollContainer';
|
||||
import { ScrollTargetComponent } from './components/scrollTarget';
|
||||
@@ -511,6 +511,12 @@ export function updateComponentStates(
|
||||
|
||||
// Update the layout
|
||||
updateLayout();
|
||||
|
||||
// If this is the first time, check if there's an #url-fragment and scroll
|
||||
// to it
|
||||
if (rootComponentId !== null) {
|
||||
scrollToUrlFragment();
|
||||
}
|
||||
}
|
||||
|
||||
function canHaveKeyboardFocus(instance: ComponentBase): boolean {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { componentsByElement } from './componentManagement';
|
||||
|
||||
export class AsyncQueue<T> {
|
||||
private waitingForValue: ((value: T) => void)[] = [];
|
||||
private values: T[] = [];
|
||||
@@ -105,3 +107,19 @@ export function copyToClipboard(text: string): void {
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(textArea);
|
||||
}
|
||||
|
||||
/// Checks if there's an #url-fragment, and if so, scrolls the corresponding
|
||||
/// ScrollTarget into view
|
||||
export function scrollToUrlFragment(): void {
|
||||
let fragment = window.location.hash.substring(1);
|
||||
if (!fragment) {
|
||||
return;
|
||||
}
|
||||
|
||||
let element = document.getElementById(fragment);
|
||||
if (element === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
element.scrollIntoView();
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ classifiers = [
|
||||
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
|
||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||
]
|
||||
version = "0.1.0"
|
||||
|
||||
[project.optional-dependencies]
|
||||
window = [
|
||||
@@ -89,7 +88,6 @@ dev-dependencies = [
|
||||
"black~=24.4.0",
|
||||
"coverage~=7.2.2",
|
||||
"pre-commit~=3.1.1",
|
||||
"pyfakefs~=5.3.0",
|
||||
"pytest~=7.3.1",
|
||||
"pyright~=1.1.350",
|
||||
"requests~=2.31",
|
||||
|
||||
Reference in New Issue
Block a user