New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tny-uturn

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tny-uturn

a small library for detecting changes in scroll direction

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

uturn - detect scrolling behavior with a requestAnimationFrame debounce

uturn.js is a small library for detecting people who change scroll direction while viewing a webpage. It uses the requestAnimationFrame events to run at 60 frames a second.

Getting started

Run the function on your site. We run this in the article pages, because those are the pages we want to create scroll events for.

Events

Create event listeners on one of the three events:

  • scrollupWhileReading This is triggered when a user is scrolling up, after having scrolled down. The desired behavior is to detect a user who scrolls up, after reading. The amount needed to be scrolled down can be modified.
  • scrolldownNormalReading This is triggered when a user is scrolling down. This is meant to be used to interupt the scrollupWhileReading event, by reengaging the reading experience.
  • scrolldownWhileReading This is triggered when the user is scrolling down. This is meant to be a general event that is triggered while a user is reading.

Callbacks

Set up eventlisters based on the above events.

You need your own functions, but here are examples:

document.addEventListener('scrolldownWhileReading', function(){
  // Put a function here that is disengages the scrolling up behavior, and returns a user to normal reading behavior
});
document.addEventListener('scrollupWhileReading', function(){
  // Put a function here that is engaged when users scroll up, after reading.
});
document.addEventListener('scrolldownNormalReading', function(){
   // Put a function here that confirms the user is scrolling down
});

FAQs

Package last updated on 23 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc