npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

detect-ios-address-bar

v0.0.6

Published

Detect iOS (>= v15) Safari's UI Overlay of the address bar on iPhones to modify your web app's UI if needed

Downloads

200

Readme

iOS Safari Detect Address Bar Overlay

The Problem

With iOS 15, Apple updated Mobile Safari to show the address bar either as a small area on the bottom or, if Safari recognizes some navigation related user input, as an overlay over the whole web page. This becomes a problem when web app's using a mobile layout that uses the bottom of your screen as a tab bar for example. That's because a navigation related user input is not just triggered by clicking on the small address bar area on the bottom (which seems to be a real navigation intention) but also when the user scrolls up.

Problem Demo

Installation

npm install detect-ios-address-bar

Usage

import SafariAddressBarDetector from 'detect-ios-address-bar'

// Initialize instance
const safariAddressBar = new SafariAddressBarDetector();

// Listening for update events
safariAddressBar.on('update', mode => {
  console.log(mode); // 'collapsed' or 'overlayed' or null if device has
});

// Get mode immediately
console.log(safariAddressBar.mode); // 'collapsed' or 'overlayed' or null

If the device is not a targeted device (Mobile Safari >= iOS 15 on iPhone or iPod Touch), the mode will be null

Destroy

Because the instance creates some global events listeners and intervals, you may like to destroy them in case of not using the instance any more.

safariAddressBar.destroy();

Modes

Currently (September of 2021) there are two modes we want to recognize on iPhones (and theoretically the iPod Touch 7th) running Mobile Safari on iOS >= 15:

  • collapsed: When the address bar is this small hint area on the bottom
  • overlayed: When the address overlays the bottom of the screen while the web page viewport lies under the address bar

Bugs

Sadly, there is one major bug: If the user scrolls down within the <body> of the page (global scroll) and the maximum scroll position is reached closely to 20px, there is no way to recognize the address bar mode anymore. This seems to be not a real problem because most apps that are offering fixed UI elements on the bottom of the screen, such as a tab bar, do not have a global scroll because they are offering an app layout. But if you're running into this issue, the best solution would be to create 20-40px space to the bottom of the page, so there is nothing that could be overlayed when the user scrolls down to the bottom of the page.