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

electron-scroller

v0.6.2

Published

Manage scrolling of content inside an Electron webview element.

Downloads

12

Readme

Electron Scroller

Electron Scroller is a package designed to manage scrolling of historical pages in <webview> tags. Webviews in electron manage page history, offering forward and back, but when navigating to the pages, the scroll position is lost. This package allows you to maintain the scroll position and automatically reposition the page to the proper scroll position upon navigation (back, forward, reload).

Installation

To install Electron Scroller, use npm. The preferred method is to install Electron Scroller as an dependency in your app:

npm install --save electron-scroller

Quick Start

It is necessary to include Electron Scroller in two places in your app:

  1. In your render javascript (called via a <script> in the HTML source)
  2. In the preload file (specified in the <webview preload="file.js")

Example HTML

<!DOCTYPE html>
<html>
<head>
  <title>Browser</title>
</head>
<body>
  <div id="buttonBar">
    ...
  </div>
  <div id="browser">
    <webview id="browserView" preload="preload.js"></webview>
  </div>
  <script src="browser.js"></script>
</body>
</html>

Render Javascript

Require the package and use the add() method. Pass to add() a string containing a single CSS selector that describes the specific webview to be managed. If only a single webview exists, the selector is not required. Because the Scroller hooks into the methods of the webview, it may be best to call add() early in the process and before configuring the webview. In this example, in the file browser.js:

const scroller = require('electron-scroller')

onload = function() {
  let selector = '#browserView'
  scroller.add(selector)
  // The selector is not required if there is only a single webview:
  // scroller.add()
}

Preload Javascript

The Scroller has to be included in the preload file by calling the preload() method. It is not necessary to pass the selector. In this example, in the file preload.js:

require('electron-scroller').preload()

License

ISC