hiswe / vh-check Goto Github PK
View Code? Open in Web Editor NEWmobile vh unit utility
Home Page: https://www.npmjs.com/package/vh-check
License: MIT License
mobile vh unit utility
Home Page: https://www.npmjs.com/package/vh-check
License: MIT License
My test case isn't calculating?
min-height: calc(98vh);@supports (height: var(--vh-offset)) {min-height: calc(98vh - var(--vh-offset));background: red;};
(@supports and its styles are crossed out in the Web Inspector. (background:red is for debugging)).
HI, We implemented vh-check in our webapp and tried it on iphone 8 and iphone X. It seems to work on iphone8 Safari but on iphoneX the height doesnt seem to adjust. I am not very familiar with the js used here but the fact that we are seeing it work on iphone8 tells me that we have implemented it correctly on our side. Any ideas why iphoneX is behaving differently?
Hello,
Very useful script, but does line 40 should exist?
I guess it says to return nothing when offset is 0, but CSS expects some value and fails when there isn't any.
I got it working by deleting 'usefullness check'...
Hello, there's a way to check if the bottom bar is opened or closed based on scroll event?
Thank you!
All iphone phones with full screen cannot use this set of plug-ins.(With a gesture bar.)
I feel like I'm dumb.. I even asked it on StackOverflow but had no luck.
How would you use this when you are using sass/scss or vue?
Let us say I have this:
<style>
:root {
--vh-offset: 0px;
--vh: 1vh;
}
.f-body #app{
min-height: calc(100vh - var(--vh-offset));
}
</style>
it always compiles to min-height: calc(100vh - 0px));
Because of this, the offset from javascript cannot work.
Thank you for reading/helping!
Hi,
When i touch and drag first time, nothing happens... But when i touch and drag again, updateOnTouch works fine.
Have some way to make updateOnTouch works more fast?
On iPad tabs auto-hide when scrolling.
And so the gap will reduce ¬_¬'
Hi There,
Thanks for the great script. I Tried to use it in normal js environment without CommonJS / RequireJS. If I do so, I get an exception at line 7 ( root.vhCheck = factory(); )
"Factory is undefined"
Any idea, what I am doing wrong?
Not working for iOS Chrome 74.0.3729.155.
This is because window.innerHeight has not been updated when an orientationchange event occurs. There is a workaround below, but I'd like to see it implemented in the library.
Workaround:
var test = vhCheck({
onUpdate: (obj: any) => {
orientationChanged().then(() => {
const cssVarName = "vh-offset";
const sizes = my.vhCheck.recompute();
document.documentElement.style.setProperty(`--${cssVarName}`, `${sizes.value}px`);
});
}
});
See this for the orientationChanged function: https://stackoverflow.com/a/44579732
Hey, just found this a few days and think it's great and solves a very annoying problem. However it seems to not be working on the newly updated google chrome V69.0.3497.105 for ios
When having a PWA standalone app (display property value is standalone in manifest.json as written in here https://developer.mozilla.org/en-US/docs/Web/Manifest/display) then this library does not work as expected - since address bar does not exist then things are calculated incorrectly.
Although (at least some) earlier versions published to NPM include the actual library, the latest (v1.1.2) doesn't appear to contain the library itself (no dist
or src
folders). Can you please publish a new version which includes the code, so that npm i vh-check
will result in a usable version being installed?
Issue 1:
In TypeScript,
import vhCheck from "vh-check";
Will result in the error:
Could not find a declaration file for module 'vh-check'.
Adding the following in package.json will resolve the issue:
"typings": "dist/vh-check.d.ts",
Issue 2:
Compiling the app with vh-check will result in the error:
ERROR in xxx/node_modules/vh-check/dist/vh-check-types.d.ts
A rest parameter must be of an array type.
> 1 | export declare type Callback = (...arg: any) => void;
Modifying the first line of vh-check-types.d.ts as below fixes the issue:
export declare type Callback = (arg: any[]) => void;
Versions:
[email protected]
[email protected]
document.documentElement.style.setProperty(
--${this.name}, this.value + 'px');
https://github.com/Hiswe/vh-check#bind
There is default: find
. Instead should be default: true
as find
is not a boolean.
isNeeded
is evaluated to be false when opening a page within a new window, and the whole thing does not work as a result. For me, it happens in iPhone/Safari.
Workaround is to set force: true
in the config depending on the User Agent,
or use setTimeout
or window.requestAnimationFrame
to delay calling vhCheck.
The value changes on zoom when updating on scroll.
AFAIK, Chrome on mobile browsers also has this behavior. See: https://developers.google.com/web/updates/2016/12/url-bar-resizing
So this shouldn't be an "iOS" gap, but should apply to all mobile browsers that have "vh" mean "viewport height as if the address bar was hidden".
You have this example:
:root {
--vh-offset: 0px;
}
main {
min-height: calc(100vh);
@supports (height: var(--vh-offset)) {
min-height: calc(100vh - var(--vh-offset));
}
}
but it seems like it should work just as well without @supports
:
:root {
--vh-offset: 0px;
}
main {
min-height: calc(100vh);
min-height: calc(100vh - var(--vh-offset));
}
var()
is not supported, that second value will be ignored, leaving you with the first 100vh
value.var()
is supported, but vh-offset isn't needed, it will be set to 0px
still, and have no effect.A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.