mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-08-14 11:49:41 +00:00
.devcontainer
.github
.vscode
plugins
sass
source
.well-known
_dashboards
_data
_docs
_faq
_includes
_integrations
_layouts
_posts
addons
android
assets
blog
blue
blueprints
changelogs
cloud
code_of_conduct
common-tasks
conference
connectzbt1
dashboards
developers
docs
faq
getting-started
green
help
home-energy-management
images
installation
integrations
ios
javascripts
libs
modernizr-2.0.js
prism.js
terminology_tooltip.js
twitter.js
more-info
privacy
security
state-of-the-open-home
static
stylesheets
tag
tos
voice-pe
voice_control
yellow
404.html
CNAME
_headers
_redirects
atom.xml
favicon.png
googlef4f3693c209fe788.html
index.html
integrations.json
robots.txt
service_worker.js
version.json
.editorconfig
.gitattributes
.gitignore
.markdownlint.json
.nvmrc
.powrc
.remarkignore
.remarkrc.js
.ruby-version
.textlintrc.json
CLA.md
CODEOWNERS
CODE_OF_CONDUCT.md
Gemfile
Gemfile.lock
LICENSE.md
README.md
Rakefile
_config.yml
config.rb
config.ru
package-lock.json
package.json

* Positioning terminology tooltip to be always fully visible #resolves https://github.com/home-assistant/home-assistant.io/issues/31341 * terminology_tooltip: removed debugs resolves7a0183402f (r1485840114)
* terminology_tooltip: removed $–convention from var names resolves7a0183402f (r1485839944)
* terminology_tooltip: let -> const --------- Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
[...document.getElementsByClassName('terminology')].forEach(terminology => {
|
|
const horizontalMargin = 20;
|
|
|
|
const topMargin = document
|
|
.getElementsByClassName('site-header')[0]
|
|
.clientHeight;
|
|
|
|
const tooltip = terminology.querySelector('.terminology-tooltip');
|
|
|
|
terminology.addEventListener('mouseenter', () => {
|
|
const tooltipRect = tooltip.getBoundingClientRect();
|
|
|
|
if (tooltipRect.top < topMargin) {
|
|
// doesn't fit on top -> moving to bottom
|
|
tooltip.classList.add('below');
|
|
}
|
|
|
|
let horizontalMove = 0;
|
|
|
|
if (tooltipRect.left < horizontalMargin) {
|
|
// doesn't fit on the left edge -> moving right
|
|
horizontalMove = Math.abs(tooltipRect.left) + horizontalMargin;
|
|
} else if (tooltipRect.right + horizontalMargin > window.innerWidth) {
|
|
// doesn't fit on the right edge -> moving left
|
|
horizontalMove = window.innerWidth - tooltipRect.right - horizontalMargin;
|
|
}
|
|
|
|
tooltip.style.setProperty('--horizontal-move', `${horizontalMove}px`);
|
|
});
|
|
|
|
terminology.addEventListener('mouseleave', () => {
|
|
// reset
|
|
tooltip.style.setProperty('--horizontal-move', '0px');
|
|
tooltip.classList.remove('below');
|
|
});
|
|
});
|