fix: fixed auto scroll on url examples on link tracking page
This commit is contained in:
parent
3701dbe3db
commit
cb47c11a14
1 changed files with 9 additions and 7 deletions
|
|
@ -194,20 +194,22 @@ TODO: explain why that is a bad thing for privacy, and personal life
|
|||
|
||||
<script>
|
||||
(function() {
|
||||
const urlExample = document.querySelector('.url-example');
|
||||
const legendItems = document.querySelectorAll('.url-legend-item[data-part]');
|
||||
|
||||
legendItems.forEach(item => {
|
||||
item.addEventListener('mouseenter', () => {
|
||||
const part = item.dataset.part;
|
||||
const urlPart = document.querySelector(`.url-example [data-part="${part}"]`);
|
||||
if (urlPart && urlExample) {
|
||||
if (urlPart) {
|
||||
const urlExample = urlPart.closest('.url-example');
|
||||
if (urlExample) {
|
||||
const containerRect = urlExample.getBoundingClientRect();
|
||||
const partRect = urlPart.getBoundingClientRect();
|
||||
const partCenter = partRect.left - containerRect.left + urlExample.scrollLeft + (partRect.width / 2);
|
||||
const scrollTarget = partCenter - (containerRect.width / 2);
|
||||
urlExample.scrollTo({ left: scrollTarget, behavior: 'smooth' });
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue