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

lofter-navigate

v0.10.9

Published

目前LOFTER APP内支持使用scheme唤起新WebView打开指定的H5 url,该功能带来的浏览体验比使用`location.href`跳转要好(页面滚动位置的保留、手势支持、过场动画等),所以在端内页面的跳转推荐优先使用scheme方案。 同时,需要与客户端约定能够同时打开WebView的最大个数,以防占用过大内存或者性能造成APP崩溃、卡顿等问题。

Downloads

149

Readme

LOFTER 统一跳转方法

背景

目前LOFTER APP内支持使用scheme唤起新WebView打开指定的H5 url,该功能带来的浏览体验比使用location.href跳转要好(页面滚动位置的保留、手势支持、过场动画等),所以在端内页面的跳转推荐优先使用scheme方案。 同时,需要与客户端约定能够同时打开WebView的最大个数,以防占用过大内存或者性能造成APP崩溃、卡顿等问题。

方案

  • 与客户端约定,最大能够同时打开WebView的个数为10个,超过10个的情况下,再次调用scheme,打开新WebView的同时关闭最早的一个WebView。
  • 客户端增加一个JSBridge协议,支持H5通过该协议获取当前App已打开的WebView数量。
  • 前端封装统一的跳转方法,端外及不支持上述JSBridge协议的客户端内使用location.href跳转新url,在支持该协议的App端内使用Scheme触发新WebView打开
  • 前端统一跳转方法在通过JSBridge协议获取到当前WebView栈个数达到10个时,回退到location.href的方式进行跳转,防止出现预期之外的WebView页面栈丢失

使用

es module引入

import {
  go,
  close,
  openWithLocation,
  openWithWebview,
} from 'lofter-navigate'

go('https://www.lofter.com')

浏览器直接引入

<button id="control" style="display: block; margin: 20px 0">带有页面栈数量控制的跳转按钮</button>
<script src="https://lofter.lf127.net/1658719740509/lofternavigate.umd.production.min.js"></script>
<script>
  $('#control').on('click', function(e) {
    e.preventDefault();
    const url = location.href + '?t=' + new Date.getTime();
    window.lofterNavigate.go(url);
  })
</script>

注意

  • 可以单独引用本SDK提供的closeopenWithLocationopenWithWebview方法,但是要自行控制好页面栈数量和使用时机。
  • 不是所有的场景都适用新WebView打开这一客户端功能,需要注意区分和鉴别。
  • go方法可以传递第二个参数maxCount,正整数类型,表示当前最大允许打开的WebView数量,默认不传时为10
  • openWithWebview可以传递第二个参数params,不传默认为{inside: true},如果需要在7.5.6版本打开透明WebView,可以传{inside: true, opacity: true},如果需要添加webview 背景颜色,不带#的色值,可以传{inside: true, opacity: true, bgColor: '213213'}