Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Bielefeld-CeBiTec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
2024 Competition
Bielefeld-CeBiTec
Commits
ab5ae403
Commit
ab5ae403
authored
5 months ago
by
Liliana Sanfilippo
Browse files
Options
Downloads
Patches
Plain Diff
scrollTo fix
parent
39a96cc0
No related branches found
No related tags found
No related merge requests found
Pipeline
#435295
failed
5 months ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/contents/engineering.tsx
+1
-0
1 addition, 0 deletions
src/contents/engineering.tsx
src/utils/TabNavigation.tsx
+12
-1
12 additions, 1 deletion
src/utils/TabNavigation.tsx
with
13 additions
and
1 deletion
src/contents/engineering.tsx
+
1
−
0
View file @
ab5ae403
...
...
@@ -3,6 +3,7 @@ import { ButtonOneEngineering } from "../components/Buttons";
import
{
LoremShort
}
from
"
../components/Loremipsum
"
;
import
{
openElement
}
from
"
../utils/openElement
"
;
import
{
H3
}
from
"
../components/Headings
"
;
import
{
useTabNavigation
}
from
"
../utils/TabNavigation
"
;
...
...
This diff is collapsed.
Click to expand it.
src/utils/TabNavigation.tsx
+
12
−
1
View file @
ab5ae403
...
...
@@ -54,6 +54,7 @@ export const useTabNavigation = () => {
const
location
=
useLocation
();
const
[
activeTab
,
setActiveTab
]
=
useState
<
string
|
null
>
(
null
);
const
[
activeSubTab
,
setActiveSubTab
]
=
useState
<
string
|
null
>
(
null
);
// Tab-Wechsel und URL-Update
const
handleTabChange
=
(
tabId
:
string
,
subTabId
?:
string
)
=>
{
...
...
@@ -74,7 +75,7 @@ export const useTabNavigation = () => {
const
tabId
=
params
.
get
(
'
tab
'
);
const
subTabId
=
params
.
get
(
'
subTab
'
);
const
collapseId
=
params
.
get
(
'
collapseId
'
);
const
scrollToId
=
params
.
get
(
'
scrollTo
'
);
// Öffne Haupt- und ggf. verschachtelten Tab
if
(
tabId
)
{
...
...
@@ -99,6 +100,16 @@ export const useTabNavigation = () => {
openFromOtherPage
(
tabId
)({
currentTarget
:
document
.
getElementById
(
tabId
)
!
});
}
if
(
scrollToId
)
{
const
element
=
document
.
getElementById
(
scrollToId
);
if
(
element
)
{
const
viewportHeight
=
window
.
innerHeight
;
const
targetPosition
=
element
.
getBoundingClientRect
().
top
+
window
.
pageYOffset
;
const
scrollToPosition
=
targetPosition
-
viewportHeight
/
2
+
element
.
clientHeight
/
2
;
window
.
scrollTo
({
top
:
scrollToPosition
,
behavior
:
"
smooth
"
});
}
}
setActiveTab
(
tabId
);
setActiveSubTab
(
subTabId
||
null
);
},
[
location
.
search
]);
...
...
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