Skip to content

Instantly share code, notes, and snippets.

@ManotLuijiu
Last active February 20, 2021 14:50
Show Gist options
  • Save ManotLuijiu/41c0f99f6e3a9abd80fb3e9a8b2d1c11 to your computer and use it in GitHub Desktop.
Save ManotLuijiu/41c0f99f6e3a9abd80fb3e9a8b2d1c11 to your computer and use it in GitHub Desktop.
WordPress Script for take care social icons toggle hide/show using Elementor & Essential Addons
document.onscroll = function () {
var e = window,
a = 'inner';
var viewportWidth;
var viewportHeight;
if (!('innerWidth' in window)) {
a = 'client';
e = document.documentElement || document.body;
}
viewportWidth = { width: e[a + 'Width'] };
vw = JSON.stringify(viewportWidth.width);
viewportHeight = { height: e[a + 'Height'] };
vh = JSON.stringify(viewportHeight.height);
document.getElementById('means__viewport__check').innerHTML =
'<div class="elementor-column-wrap elementor-element-populated"><div class="elementor-widget-wrap">\
<div class="elementor-element elementor-align-right elementor-widget elementor-widget-breadcrumbs">\
<div class="elementor-widget-container"><p id="means__viewport__p">\
<span class="breadcrumb_last" style="color: #808285">มิติของหน้าจอ(กว้าง x สูง)</span>\
<span style="color: #e33371">' +
' ' +
vw +
'x' +
vh +
' px</span></p></div></div></div></div>';
// handle social icons at footer
if (
document.getElementById('means__social__th') &&
document.getElementById('means__social__icons__upper')
) {
if (
window.innerHeight + window.scrollY + 2000 > document.body.clientHeight &&
vw <= 2200
) {
document.getElementById('means__social__th').style.display = 'none';
document.getElementById('means__social__icons__upper').style.display =
'block';
} else if (
window.innerHeight + window.scrollY + 2000 > document.body.clientHeight &&
vw > 2200
) {
document.getElementById('means__social__th').style.display = 'none';
document.getElementById('means__social__icons__upper').style.display =
'none';
} else if (
window.innerHeight + window.scrollY + 2000 < document.body.clientHeight &&
vw <= 2200
) {
document.getElementById('means__social__th').style.display = 'none';
document.getElementById('means__social__icons__upper').style.display =
'block';
} else {
document.getElementById('means__social__th').style.display = 'block';
document.getElementById('means__social__icons__upper').style.display =
'none';
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment