-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create screen test and capture css media fingerprint #97
Comments
https://abrahamjuliot.github.io/creepjs/tests/screen.html orientation and viewport are |
https://jsfiddle.net/873kspn4/1/ FF nightly 86 RFP off = prefersColorScheme: "", prefersReducedMotion: "" What does import gain over just a straight css (besides the fact that JS can read it quickly) |
I'm now discovering, FF has
Oops, that's a bug I left in there. Fixed.
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1579584#c5 and subsequent comments I've been letting android tests lapse. Anyway, if I read that right, then we can detect if dynamic toolbar is enabled? I should make a test: i.e if enabled 100vh - inner = toolbar height ... if disabled 100vh - inner = zero wanna test that for me? |
I do not know what you mean by I have questions. Using Firefox Nightly on Android. RFP off on the left, RFP on on the right screen test
creepy test
|
This seems the same as obtaining 100vh and inner (the difference is only unspoken). I'm not sure how 100vh were obtained to verify this, but const hasToolbar = !!(document.documentElement.clientHeight - window.innerHeight) |
|
Android > Firefox > Settings > General > Customize > Scroll to hide toolbar (default = on) |
const vViewport = 'visualViewport' in window ? visualViewport : { }
const { width: viewportWidth, height: viewportHeight } = vViewport
console.log(`${Math.round(viewportWidth)} x ${Math.round(viewportHeight)}`)
// gcd is based on https://stackoverflow.com/a/1186465
const gcd = (a, b) => b == 0 ? a : gcd(b, a%b)
const { innerWidth, innerHeight } = window
const { width: screenWidth, height: screenHeight } = screen
const ratio = gcd(innerWidth, innerHeight)
const screenRatio = gcd(screenWidth, screenHeight)
const aspectRatio = `${innerWidth/ratio}/${innerHeight/ratio}`
const deviceAspectRatio = `${screenWidth/screenRatio}/${screenHeight/screenRatio}` /*css*/
@media (aspect-ratio: ${aspectRatio}) {
body {--viewport-aspect-ratio: ${aspectRatio};}
}
@media (device-aspect-ratio: ${deviceAspectRatio}) {
body {--device-aspect-ratio: ${deviceAspectRatio};}
} |
I'm not sure there is practical method to detect this since the toolbar is only hidden when/if the user scrolls. |
I use an iframe for the screen metrics on creep, and as far as I know RFP restricts screen metrics in iframes. |
what are you using for getting vunits? function get_vunits() {
let div, vh1, vw1
div = document.createElement("vunits")
div.style.height = "100vh"
div.style.width = "100vw"
div.style.maxHeight = "none"
div.style.boxSizing = "content-box"
document.body.appendChild(div)
vw1 = div.clientWidth
vh1 = div.clientHeight
document.body.removeChild(div)
console.log(vw1 +" x "+ vh1) // I get 0x0 .. approx 2ms
function vh(v) {
let h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
return (v * h) / 100;
}
function vw(v) {
let w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
return (v * w) / 100;
}
function vmin(v) {
return Math.min(vh(v), vw(v));
}
function vmax(v) {
return Math.max(vh(v), vw(v));
}
console.log(vw(100), Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
console.log(vh(100), Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
console.log(vmin(100));
console.log(vmax(100)); // approx 1 or 2 ms
} |
Yes. The screen shots are from my realsies android
entropy is good: we get this (decimals) on TZP when devicePixelRatio is not 1. Just wondering why the value changed edit: there is also this: https://devicepixelratio.glitch.me/ PS: I have been looking at expanding other measuring methods in the screen section for some time
Would be nice to list get all this into TZP |
I use |
That's sounds awesome. I'll take a look and try it out. |
^^ big edit 3 posts up :) edit: and intersection observer which I have a poc lying around |
the decimal places happen because of the real devicePixelRatio, not because I factor in the reported dPR Here is my realsies android with RFP on |
https://developer.mozilla.org/en-US/docs/Web/CSS/@media
getComputedStyle
: https://jsfiddle.net/jrnca3wh/@import
can access media queries: https://jsfiddle.net/s8xcg0ou/3/The text was updated successfully, but these errors were encountered: