Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

transcroll

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

transcroll

Animate scroll in a modern way

  • 1.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by16.67%
Maintainers
1
Weekly downloads
 
Created
Source

Transcroll

Animate scroll in a flexible, user-friendly, simple and modern way.

Install with npm i transcroll.

Usage:

import transcroll, { easings } from './index';

// animate to an element
transcroll(document.querySelector('#whatever'));

// animate to an element by selector string
transcroll('#whatever');

// animate to position
transcroll(200);

// configuration options and default values
transcroll(whatever, {
	// scrollable container element
	el: window,
	
	// scrolling axis, 'x' or 'y'
	axis: 'y',

	// animation duration
	duration: 200,

	// transition easing function, can be a function or a string with an easings object key
	easing: easings.easeInQuad,

	// jump factor or false to disable (more information below)
	jump: 2,

	// immediately stop animation if user uses a mousewheel
	interrupt: true
});

// do something on animation end
transcroll(whatever).then(({
	// animation started after "jump" is triggered
	jumped,
	// animation was interrupted by user
	interrupted
}) => doSomething());

Jump factor

jump argument is used to calculate a threshold value which is used to prevent animating too big distances in a short period of time.

threshold = duration * jumpFactor

You can feel same behavior in the Telegram application when trying to scroll to the last message in a chat after scrolling back to some old messages about 4-5 screens.

FAQs

Package last updated on 19 May 2018

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