Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tsinghua
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
Package registry
Model registry
Operate
Terraform modules
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
Zhefu Li
Tsinghua
Commits
22896a9e
Commit
22896a9e
authored
6 months ago
by
HouTeng Chan
Browse files
Options
Downloads
Patches
Plain Diff
Update file home.html
parent
d29f70b1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wiki/pages/home.html
+80
-70
80 additions, 70 deletions
wiki/pages/home.html
with
80 additions
and
70 deletions
wiki/pages/home.html
+
80
−
70
View file @
22896a9e
...
...
@@ -303,7 +303,6 @@
</div>
</div>
<!-- Add the sine wave container and sachet image container -->
<div
id=
"sine-wave-container"
>
<svg
id=
"sine-wave-animation"
xmlns=
"http://www.w3.org/2000/svg"
></svg>
...
...
@@ -312,7 +311,6 @@
<img
src=
"https://static.igem.wiki/teams/5187/art/icon.png"
alt=
"Sachet"
id=
"sachet-image"
>
</div>
<footer
class=
"footer"
>
<div
class=
"footer-content"
>
<div
class=
"social-icons"
>
...
...
@@ -369,83 +367,95 @@
});
// Added JavaScript for sine wave animation
window
.
addEventListener
(
'
DOMContentLoade
d
'
,
function
()
{
window
.
addEventListener
(
'
loa
d
'
,
function
()
{
const
svg
=
document
.
getElementById
(
'
sine-wave-animation
'
);
const
sachetImage
=
document
.
getElementById
(
'
sachet-image
'
);
// Get the sachet image height
const
sachetHeight
=
sachetImage
.
offsetHeight
||
0
;
const
width
=
100
;
// Width of the SVG
const
height
=
window
.
innerHeight
-
sachetHeight
;
// Height from top to sachet
svg
.
setAttribute
(
'
width
'
,
width
);
svg
.
setAttribute
(
'
height
'
,
height
);
// Parameters for sine waves
const
amplitudes
=
[
20
,
15
,
10
];
// Amplitude of each sine wave
const
frequencies
=
[
5
,
7
,
9
];
// Number of cycles for each sine wave
const
offsets
=
[
30
,
50
,
70
];
// Horizontal positions
const
colors
=
[
'
pink
'
,
'
pink
'
,
'
pink
'
];
// Color of the sine waves
const
paths
=
[];
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
const
pathData
=
createVerticalSineWavePath
(
amplitudes
[
i
],
frequencies
[
i
],
0
,
offsets
[
i
],
width
,
height
,
500
);
const
path
=
document
.
createElementNS
(
'
http://www.w3.org/2000/svg
'
,
'
path
'
);
path
.
setAttribute
(
'
d
'
,
pathData
);
path
.
setAttribute
(
'
stroke
'
,
colors
[
i
]);
path
.
setAttribute
(
'
fill
'
,
'
none
'
);
path
.
setAttribute
(
'
stroke-width
'
,
2
);
path
.
setAttribute
(
'
id
'
,
'
sinewave
'
+
i
);
svg
.
appendChild
(
path
);
// Get the length of the path
const
length
=
path
.
getTotalLength
();
// Set up the stroke-dasharray and stroke-dashoffset
path
.
style
.
strokeDasharray
=
length
;
path
.
style
.
strokeDashoffset
=
length
;
paths
.
push
({
path
:
path
,
length
:
length
});
}
function
createVerticalSineWavePath
(
amplitude
,
frequency
,
phase
,
horizontalOffset
,
width
,
height
,
points
)
{
let
path
=
""
;
for
(
let
i
=
0
;
i
<=
points
;
i
++
)
{
let
y
=
(
i
/
points
)
*
height
;
let
x
=
amplitude
*
Math
.
sin
(
frequency
*
(
y
/
height
)
*
2
*
Math
.
PI
+
phase
)
+
horizontalOffset
;
if
(
i
===
0
)
{
path
+=
"
M
"
+
x
+
"
"
+
y
+
"
"
;
}
else
{
path
+=
"
L
"
+
x
+
"
"
+
y
+
"
"
;
// Ensure the sachet image has loaded
sachetImage
.
onload
=
function
()
{
initializeSineWave
();
};
// If the image is cached and already loaded
if
(
sachetImage
.
complete
)
{
initializeSineWave
();
}
function
initializeSineWave
()
{
// Get the sachet image height
const
sachetHeight
=
sachetImage
.
offsetHeight
||
0
;
const
width
=
100
;
// Width of the SVG
const
height
=
window
.
innerHeight
-
sachetHeight
-
50
;
// Height from top to sachet
svg
.
setAttribute
(
'
width
'
,
width
);
svg
.
setAttribute
(
'
height
'
,
height
);
// Parameters for sine waves
const
amplitudes
=
[
20
,
15
,
10
];
// Amplitude of each sine wave
const
frequencies
=
[
5
,
7
,
9
];
// Number of cycles for each sine wave
const
offsets
=
[
50
,
50
,
50
];
// Horizontal positions
const
colors
=
[
'
pink
'
,
'
pink
'
,
'
pink
'
];
// Color of the sine waves
const
paths
=
[];
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
const
pathData
=
createVerticalSineWavePath
(
amplitudes
[
i
],
frequencies
[
i
],
0
,
offsets
[
i
],
width
,
height
,
500
);
const
path
=
document
.
createElementNS
(
'
http://www.w3.org/2000/svg
'
,
'
path
'
);
path
.
setAttribute
(
'
d
'
,
pathData
);
path
.
setAttribute
(
'
stroke
'
,
colors
[
i
]);
path
.
setAttribute
(
'
fill
'
,
'
none
'
);
path
.
setAttribute
(
'
stroke-width
'
,
2
);
path
.
setAttribute
(
'
id
'
,
'
sinewave
'
+
i
);
svg
.
appendChild
(
path
);
// Get the length of the path
const
length
=
path
.
getTotalLength
();
// Set up the stroke-dasharray and stroke-dashoffset
path
.
style
.
strokeDasharray
=
length
;
path
.
style
.
strokeDashoffset
=
length
;
paths
.
push
({
path
:
path
,
length
:
length
});
}
function
createVerticalSineWavePath
(
amplitude
,
frequency
,
phase
,
horizontalOffset
,
width
,
height
,
points
)
{
let
path
=
""
;
for
(
let
i
=
0
;
i
<=
points
;
i
++
)
{
let
y
=
(
i
/
points
)
*
height
;
let
x
=
amplitude
*
Math
.
sin
(
frequency
*
(
y
/
height
)
*
2
*
Math
.
PI
+
phase
)
+
horizontalOffset
;
if
(
i
===
0
)
{
path
+=
"
M
"
+
x
+
"
"
+
y
+
"
"
;
}
else
{
path
+=
"
L
"
+
x
+
"
"
+
y
+
"
"
;
}
}
return
path
;
}
return
path
;
}
window
.
addEventListener
(
'
scroll
'
,
function
()
{
const
scrollTop
=
window
.
scrollY
||
window
.
pageYOffset
;
const
scrollHeight
=
document
.
body
.
scrollHeight
-
window
.
innerHeight
;
window
.
addEventListener
(
'
scroll
'
,
function
()
{
const
scrollTop
=
window
.
scrollY
||
window
.
pageYOffset
;
const
scrollHeight
=
document
.
body
.
scrollHeight
-
window
.
innerHeight
;
// Calculate the scroll percentage
const
scrollPercent
=
scrollTop
/
scrollHeight
;
// Calculate the scroll percentage
const
scrollPercent
=
scrollTop
/
scrollHeight
;
// For each path, adjust the stroke-dashoffset
paths
.
forEach
(
function
(
item
)
{
const
drawLength
=
item
.
length
*
scrollPercent
;
item
.
path
.
style
.
strokeDashoffset
=
item
.
length
-
drawLength
;
// For each path, adjust the stroke-dashoffset
paths
.
forEach
(
function
(
item
)
{
const
drawLength
=
item
.
length
*
scrollPercent
;
item
.
path
.
style
.
strokeDashoffset
=
item
.
length
-
drawLength
;
});
});
}
);
}
});
</script>
</html>
\ No newline at end of file
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