Scripts
This commit is contained in:
+3
-21
@@ -1,31 +1,13 @@
|
||||
var isInMobile = false;
|
||||
|
||||
// Создаём экземпляр ResizeObserver с функцией-колбэком
|
||||
const jsinjectObserver = new ResizeObserver((entries) => {
|
||||
for (let entry of entries) {
|
||||
const rect = entry.contentRect; // Размеры контентной области
|
||||
console.log('Новые размеры:', rect.width, 'x', rect.height);
|
||||
|
||||
if (isInMobile) {
|
||||
// Здесь можно выполнять любые действия при изменении размера
|
||||
entry.target.style.borderColor = `hsl(${rect.width % 360}, 50%, 50%)`;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Начинаем наблюдение за конкретным элементом
|
||||
const jsSideNav = document.querySelector('.side-nav');
|
||||
jsinjectObserver.observe(jsSideNav);
|
||||
|
||||
|
||||
function jsinject_init() {
|
||||
let navy = document.getElementById('side-nav');
|
||||
if (visualViewport.width < visualViewport.height) {
|
||||
document.body.style.width = '100%';
|
||||
navy.style.width = '6px';
|
||||
navy.onclick = (function () {
|
||||
if (navy.clientWidth > 6) {
|
||||
navy.style.width = 6;
|
||||
if (navy.clientWidth > 0) {
|
||||
navy.style.width = 0;
|
||||
}
|
||||
else {
|
||||
navy.style.width = document.body.clientWidth + 'px';
|
||||
@@ -36,6 +18,6 @@ function jsinject_init() {
|
||||
else {
|
||||
document.body.style.width = '80%';
|
||||
document.body.style.margin = 'auto';
|
||||
navy.style.left = document.body.clientLeft + 'px';
|
||||
navy.style.marginLeft = document.body.clientLeft + 'px';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user