Here is my problem:
I want to have an "addEventListener" click method only for browser size smaller than "400px". But when we resize the browser, I want to remove this method.
The format of my code is below. If I grow up the browser over 400px I…
I have some problem with the matchMedia function that I wrote inside my computed property in Vue. The problem is when I load/refresh page, the function does not work.
It only back to work after I resize the screen in Responsive Design Mode at the…
I'm building a plugin and for the toggling certain behaviour on/off, I'm using the matchMedia functions. However in the callback function, I need to pass an argument to retain the right reference to this. However, when I try to pass an argument to…
window.matchMedia is working, but I thought it would work like using '@media only screen and' works where when the screen is narrowed it happens. With window.matchMedia the screen has to be loaded or refreshed if you're on a desktop browser for…
First of all, I would like to highlight that I am quite a newbie in javascript programming and am trying to learn as much as I can from here. Reading the enquire js api, documentations as well as the sourcecode. I would like to know what is the…
I'm using the following to detect if the app is running from the installed PWA or the browser version:
if (window.matchMedia('(display-mode: standalone)').matches) {
alert('app is installed');
} else alert('app is not installed');
It…
I need to have a reactive global variable in Vue. The variable is simply a boolean that tells me whether the user is on a mobile device. I have tried so many things but this is the last thing I tried:
Vue.prototype.$testIsMobile = false
const…
I only want to run a script when the viewport width is greater than a set value. I would also like this to check as the browser resizes and disable/enable as required. I've tried to achieve this using matchMedia and rather than checking every pixel,…
I have tried so many method to stop this error but nothing seems to work, here is a link to my codepen: https://codepen.io/T_manuel/pen/PoKMYVx
when the page loads, I call the function but when I resize the page, Javascript seems to do the new logic…
I'm using JavaScript together with a css column-width layout to calculate breakpoints at each new column in the browser window. With each new column I also increase the page margins for which I calculate a second breakpoints so they fit.
I have…
I'm trying to trigger different GSAP timelines at different breakpoints using the window.matchmedia(); method.
I've attempted to put together a simple example here to explain my thinking:
const box = document.querySelector(".box");
const change =…
I'd like to execute a listener function (that adds class, "cursor-white") that occurs ONLY IF the 2 following conditions are met.
$(window).scrollTop is 0 (at the top of window)
and the window is <= 900px.
Im struggling with getting the logic…
I'd like to know about using/unused by user invert color mode (wcag) (standard windows/mac function for visually impaired people )...this mode active or inactive. Is it possible?
I'm trying to use window.matchMedia('(-ms-high-contrast: active)') for…
Hey friends I'm trying to use window.matchMedia("(max-width: 1700px)") to add some elements in the html when the page is 1700px or smaller. Right now I'mk just trying to test it by have a function alert 'yo' to the screen. This doesn't work as well…