I run a WordPress site with a custom header. Therefore, I decided to rely on jQuery.
I have a menu (#sitenavigation) that appears when I hover over a container it's in (#menuhover). I only want this to work in viewports that are 1025px and wider…
I want to add horizontal scrolling to a page on larger screens. On smaller screens it should be regular, vertical scrolling. Like this website: https://www.studiorhe.com/
function horizontalScroll(elem) {
let scrolly = (e) => {
…
I'm trying to replace gray box PNG with red box SVG, whose width should vary depending on the screen width.
This is the working code using .replaceWith() before implementing window.matchMedia()
$(document).ready(function(){
…
When I add matchMedia listener:
matchMedia('print').onchange = (m) => { console.log('print matches', m.matches)}
And I open print dialog, I always see two logs:
print matches true
print matches false
After firing callback with value true, there is…
On mobile I have 2 panels/draws that are the width of the viewport (side by side). There is a link to toggle which one is in view and when clicked, this slides the panels left/right.
However on desktop, this isn't needed as they are both in view. So…
I am using if (window.matchMedia().matches to swap some background images on an element depending on the screen resolution. When l resize the page the new (window.matchMedia().matches runs the code within the matchMedia but also continues to run the…
I create a composable function to detect current screen resolution (this function works).
If I use this function in a few components, addEventListener add a new handler to the same mediaQuery. How can I manage that mediaQuery already has a…
I have a basic gsap animation set up with matchMedia.
ScrollTrigger.matchMedia({
"(min-width: 700px)": function () {
let containerWidth = parseInt(getComputedStyle(document.querySelector(".see-through")).width);
let tl =…
I am using reactjs with nextjs, i am having the following problem.
When the page is loaded I have to set a variable which should tell me if user is using dark mode or not.
I did the following, but I'm not sure if it's correct.
I had to set a value,…
I'm detecting device orientation using window.matchMedia. The following code works as intended - every orientation change is logged to console with correct value:
Below is the code snippet used in one of the tutorials I am learning from now. Can someone please help to understand how an argument 'mediastate' can be passed to a variable 'transientListen' in the 'notify' function?
function…
I'm trying to use the window.matchMedia event listener to detect if the user is on a touch device or not. But im just seems to be only activate when the chrome DevTools window is resized, and not actually detect if it is a touch device (for example,…
Im trying to toggle a click event listener using matchmedia. My goal is to add the eventlistener when the screen size is less than or equal 768px and removeEventListener above 768px. The event listener is removed and added when I write them as…