Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
leximpact-legi-ui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
leximpact
Exploration
leximpact-legi-ui
Commits
be270c26
Commit
be270c26
authored
2 months ago
by
David Smadja
Browse files
Options
Downloads
Patches
Plain Diff
Allow navigation using hash link from Bill
parent
78016e9e
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib/components/Bill.svelte
+33
-9
33 additions, 9 deletions
src/lib/components/Bill.svelte
with
33 additions
and
9 deletions
src/lib/components/Bill.svelte
+
33
−
9
View file @
be270c26
...
...
@@ -5,11 +5,21 @@
let
container
:
HTMLDivElement
const
scrollToAnchor
=
(
hash
:
string
,
shadowRoot
:
ShadowRoot
)
=>
{
if
(
!
hash
)
return
const
id
=
hash
.
substring
(
1
)
// Enlève le #
const
element
=
shadowRoot
.
getElementById
(
id
)
if
(
element
)
{
element
.
scrollIntoView
({
behavior
:
"
smooth
"
})
}
}
$effect
(()
=>
{
if
(
!
container
||
!
billHTML
)
return
if
(
!
container
.
shadowRoot
)
{
const
shadow
=
container
.
attachShadow
({
mode
:
"
open
"
})
;
const
shadow
=
container
.
attachShadow
({
mode
:
"
open
"
})
// Crée un conteneur position:relative dans le Shadow DOM
shadow
.
innerHTML
=
`
...
...
@@ -26,11 +36,25 @@
}
</style>
<div class="content-wrapper">
${
billHTML
}
</div>
`
;
`
scrollToAnchor
(
window
.
location
.
hash
,
shadow
)
shadow
.
addEventListener
(
"
click
"
,
(
e
)
=>
{
const
link
=
(
e
.
target
as
HTMLElement
).
closest
(
'
a[href^="#"]
'
)
if
(
link
)
{
e
.
preventDefault
()
const
hash
=
link
.
getAttribute
(
"
href
"
)
if
(
hash
)
{
// Met à jour l'URL du navigateur
window
.
history
.
pushState
(
null
,
""
,
hash
)
scrollToAnchor
(
hash
,
shadow
)
}
}
})
}
else
{
// Met à jour seulement le contenu, pas la structure
const
wrapper
=
container
.
shadowRoot
!
.
querySelector
(
'
.content-wrapper
'
);
if
(
wrapper
)
wrapper
.
innerHTML
=
billHTML
;
const
wrapper
=
container
.
shadowRoot
!
.
querySelector
(
"
.content-wrapper
"
)
if
(
wrapper
)
wrapper
.
innerHTML
=
billHTML
}
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment