Giter Site home page Giter Site logo

hiswe / vh-check Goto Github PK

View Code? Open in Web Editor NEW
417.0 10.0 16.0 686 KB

mobile vh unit utility

Home Page: https://www.npmjs.com/package/vh-check

License: MIT License

JavaScript 17.82% HTML 8.02% CSS 7.81% TypeScript 66.35%
css buggyfill ios vh chrome android

vh-check's Issues

@supports not working on iOS 9.3.2?

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)).

Doesn't seem to work on Iphone X

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?

usefullness check

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'...

Help: How can I use it with sass or vue?

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!

root object in factory is undefined

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?

Does not work in iOS Chrome

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

Not working on new chrome ios

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

Publish actual code to NPM

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?

Issues with TypeScript

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]

Bottom gap on mobile Firefox

I’m testing the mobile demo site on Firefox for iOS on a iPhone XR and I notice a bottom gap (see the black bar).

F9F0D968-783F-44ED-8146-9A901A5EF536

isNeeded = false for iPhone/Safari when target=_blank

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.

Is there any reason to use `@supports` here?

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));
}
  • If var() is not supported, that second value will be ignored, leaving you with the first 100vh value.
  • If var() is supported, but vh-offset isn't needed, it will be set to 0px still, and have no effect.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.