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

typewrite

v1.0.0

Published

Adds typewriter scrolling to textareas (text moves up, caret does not)

Downloads

4

Readme

typewrite

typewrite adds typewriter scrolling to a textarea.

About typewriter scrolling

Typewriter scrolling keeps a user's caret at a constant y-position on the screen. When the user types text preceding the caret moves up, as on a typewriter, instead of the caret moving down. This ensures the user never has to type at the bottom edge of the screen and can always view the text immediately surrounding the caret on either side. Most dedicated prose editors (e.g., WriteRoom, Scrivener, Ulysses) have typewriter scrolling options.

Demo GIF

Example

<textarea></textarea>
var typewrite = require('typewrite');
var textarea = document.querySelector("textarea");
typewrite(textarea);

(Use browserify or equivalent to require npm modules in web apps.)

Autosize

typewrite depends on autosizing textareas. I might fix that later, but for now if you don't want autosize, just wrapping your textarea in a div with overflow-y:auto should work.

Options

The second argument to typewrite() may be an options object:

typewrite(textareaElement, {
  scrollingCutoff: 0.7,
  bottomMarginSize: 0.3
});

scrollingCutoff

Default: 0.7

Controls the y-coordinate below which to enable typewriter scrolling. Function accepting the container height and the caret position (in pixels) and returning true or false.

// typewriter scrolling enabled when caret is in the bottom 30% of the container
options.scrollingCutoff = function(caretYPosition, writingAreaHeight) {
  return caretYPosition / writingAreaHeight > 0.7;
};

scrollingCutoff can also be a number indicating the fraction of the container height below which scrolling should be enabled.

// typewriter scrolling enabled when caret is in the bottom 30% of the container
options.scrollingCutoff = 0.7;

bottomMarginSize

Default: 0.3

Controls the size of the blank space after the last line. Function accepting the container height and returning a number in pixels.

// space will be 30% of the container height
options.bottomMarginSize = function(containerHeight) {
  return containerHeight * 0.3;
}

bottomMarginSize can also be a number indicating the fraction of the height of the container the space should be.

// space will be 30% of the container height
options.bottomMarginSize = 0.3;