Giter VIP home page Giter VIP logo

on-screen-keyboard-detector's People

Contributors

jer-sen avatar semmel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

on-screen-keyboard-detector's Issues

Top-level declaration error in ionc/angular project

Im running an Ionic project with angular 9.1.12 and get the following error when trying to build:

ERROR in node_modules/on-screen-keyboard-detector/src/osk-detector.d.ts:1:1 - error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier.

1 const oskd: {

Incorrect detection dismissing KB at page bottom in iOS Safari 15.0-beta+6

To reproduce with demo/index.html:

  • focus an input
  • Pinch zoom
  • scroll to the bottom
  • hit done on the OSK dismissing the KB
    --> Error KB still detected.

Not happens on previous (stable) Safari.

Analysis

Scroll position completely awkward, possible window missing a scroll event because the window is not scrolled after hitting done.

Usage of screen.orientation.type fails on desktop Safari

I had to roll back my use of this package because it crashes on browsers where screen.orientation.type is not supported, most notably on desktop Safari. ๐Ÿ˜”

screen.orientation.type.startsWith('portrait') ? 'portrait' : 'landscape',

Here's the compatibility table: https://developer.mozilla.org/en-US/docs/Web/API/Screen/orientation

I hope you're able to implement this without using the screen.orientation API, or if not add these unsupported browsers to the limitations in the README!

React V 18.0 Support

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR! react@"18.1.0" from the root project

Safari 15.3 error with screen.orientation.type

First of all, thanks for your work @semmel ๐Ÿ™Œ , we are working with this tool, but sometimes we got the error below, can we add a validation in the getScreenOrientationType function before evaluating the screen variable?

undefined is not an object (evaluating 'screen.orientation.type')

screen.orientation.type.startsWith('portrait') ? 'portrait' : 'landscape',

Operating systemย  Mac OS X
Version 10.15.7
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15

Using virtual keyboard

I've been using this lib for a while happily, thanks! But it, unfortunately, stopped working recently after an upgrade to React18 and a bunch of other stuff. Not sure what exactly caused it. I also noticed this uses rambda which is not ideal for us as it's the only place it's used so it adds extra dependency. As we use react + typescript, I put together the following replacement. Maybe somebody else will find it useful so posting it here:

import { useEffect, useState } from 'react';

interface GeometryChangeEvent {
  target: { boundingRect: DOMRect };
}

interface VirtualKeyboard {
  addEventListener(
    type: 'geometrychange',
    listener: (e: GeometryChangeEvent) => void
  ): void;
  removeEventListener(
    type: 'geometrychange',
    listener: (e: GeometryChangeEvent) => void
  ): void;
  overlaysContent: boolean;
}

declare global {
  interface Navigator {
    virtualKeyboard?: VirtualKeyboard;
  }
}

const useOnScreenKeyboard = (): boolean => {
  const [isKeyboardVisible, setKeyboardVisibility] = useState(false);

  useEffect(() => {
    if (!navigator.virtualKeyboard) {
      console.warn('Virtual Keyboard API not supported');
      return;
    }
    const handleKeyboardChange = (e: GeometryChangeEvent): void => {
      const { width, height } = e?.target?.boundingRect ?? {};
      setKeyboardVisibility(height > 0 || width > 0);
    };
    navigator.virtualKeyboard.overlaysContent = true;
    navigator.virtualKeyboard.addEventListener(
      'geometrychange',
      handleKeyboardChange
    );
    return () => {
      navigator.virtualKeyboard.removeEventListener(
        'geometrychange',
        handleKeyboardChange
      );
    };
  }, []);

  return isKeyboardVisible;
};

export default useOnScreenKeyboard;

Keep in mind you'll have to put something like this:

body {
  padding-bottom: env(keyboard-inset-height, 0px);
}

In your CSS to achieve similar results to the default behavior.

A bunch of the Type declarations in the code will eventually be omitted once official support is there. Hope it comes in handy for somebody!

Getting an error running in Nextjs project

SyntaxError: Cannot use import statement outside a module

This error happened while generating the page. Any console logs will be displayed in the terminal window.

image
image

I'm not familiar with @most/core

97.2% of the lib size is Ramda + Most.js

This lib has about 250 SLoC, but it weighs 12.6kB gzipped because it brings a lot of stuff from Ramda and Most.js. Is there any chance it can be rewritten in plain JS? The two major benefits would be:

  • It would probably go down to less than 1kB gzipped
  • It would be easier for people to contribute, debug if needed, or even just quickly read the code and learn how it works without the need to understand how Ramda and Most.js work

image
https://bundlephobia.com/package/[email protected]

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.