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

smart-sections

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smart-sections - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

25

dist/bundle.cjs.js

@@ -465,3 +465,3 @@ 'use strict';

var fixedReadingLine = calculateFixedReadingLine(scrollTop, viewportHeight);
var readingLineFromTop = scrollTop * 2;
var readingLineFromTop = scrollTop * 2 + 1;
var scrollBottom = documentHeight - viewportHeight - scrollTop;

@@ -477,2 +477,9 @@ var readingLineFromBottom = documentHeight - scrollBottom * 3 - 1;

function calculateScroll(readingLine, viewportHeight, documentHeight) {
var scrollWhenMiddle = readingLine - viewportHeight / 3;
var scrollWhenTop = (readingLine - 1) / 2;
var scrollWhenBottom = (readingLine + 1 - documentHeight) / 3 + documentHeight - viewportHeight;
return Math.max(Math.min(scrollWhenMiddle, scrollWhenBottom), scrollWhenTop);
}
var defineProperty = function (obj, key, value) {

@@ -534,14 +541,14 @@ if (key in obj) {

var viewportHeight = getViewportHeight();
var documentHeight = getDocumentHeight();
var sectionEl = sections[sectionName];
var elementCoordinates = coordinatesFromSection(sectionEl);
var isTheLastElement = Object.keys(sections)[Object.keys(sections).length - 1] === sectionName;
var toBottom = elementCoordinates.bottom - viewportHeight / 3;
var toTop = elementCoordinates.top;
if (isTheLastElement) return toTop;
var result = Math.min(toBottom, toTop);
var readingLine = calculateReadingLine(result, viewportHeight, getDocumentHeight());
if (readingLine > elementCoordinates.bottom) {
return result - (readingLine - elementCoordinates.bottom) / 3;
var scrollToTop = calculateScroll(toTop, viewportHeight, documentHeight) + 1;
var onTopFixedReadingLine = calculateFixedReadingLine(scrollToTop, viewportHeight);
var scrollToBottom = calculateScroll(elementCoordinates.bottom, viewportHeight, documentHeight) - 1;
if (onTopFixedReadingLine < elementCoordinates.top) {
return scrollToBottom;
}
return result;
return scrollToTop;
}

@@ -548,0 +555,0 @@

@@ -461,3 +461,3 @@ var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

var fixedReadingLine = calculateFixedReadingLine(scrollTop, viewportHeight);
var readingLineFromTop = scrollTop * 2;
var readingLineFromTop = scrollTop * 2 + 1;
var scrollBottom = documentHeight - viewportHeight - scrollTop;

@@ -473,2 +473,9 @@ var readingLineFromBottom = documentHeight - scrollBottom * 3 - 1;

function calculateScroll(readingLine, viewportHeight, documentHeight) {
var scrollWhenMiddle = readingLine - viewportHeight / 3;
var scrollWhenTop = (readingLine - 1) / 2;
var scrollWhenBottom = (readingLine + 1 - documentHeight) / 3 + documentHeight - viewportHeight;
return Math.max(Math.min(scrollWhenMiddle, scrollWhenBottom), scrollWhenTop);
}
var defineProperty = function (obj, key, value) {

@@ -530,14 +537,14 @@ if (key in obj) {

var viewportHeight = getViewportHeight();
var documentHeight = getDocumentHeight();
var sectionEl = sections[sectionName];
var elementCoordinates = coordinatesFromSection(sectionEl);
var isTheLastElement = Object.keys(sections)[Object.keys(sections).length - 1] === sectionName;
var toBottom = elementCoordinates.bottom - viewportHeight / 3;
var toTop = elementCoordinates.top;
if (isTheLastElement) return toTop;
var result = Math.min(toBottom, toTop);
var readingLine = calculateReadingLine(result, viewportHeight, getDocumentHeight());
if (readingLine > elementCoordinates.bottom) {
return result - (readingLine - elementCoordinates.bottom) / 3;
var scrollToTop = calculateScroll(toTop, viewportHeight, documentHeight) + 1;
var onTopFixedReadingLine = calculateFixedReadingLine(scrollToTop, viewportHeight);
var scrollToBottom = calculateScroll(elementCoordinates.bottom, viewportHeight, documentHeight) - 1;
if (onTopFixedReadingLine < elementCoordinates.top) {
return scrollToBottom;
}
return result;
return scrollToTop;
}

@@ -544,0 +551,0 @@

{
"name": "smart-sections",
"version": "0.0.5",
"version": "0.0.6",
"description": "Framework agnostic, vertical scroll solution that follows what you actually read",

@@ -17,4 +17,9 @@ "main": "dist/bundle.cjs.js",

"start": "nps",
"prepublish": "yarn start build"
"prepublish": "yarn start build",
"watch": "npm-watch",
"test": "jest"
},
"watch": {
"prepublish": "src/*.js"
},
"dependencies": {

@@ -25,5 +30,8 @@ "lodash.throttle": "^4.1.1"

"babel-core": "^6.26.0",
"babel-jest": "^22.4.3",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-2": "^6.24.1",
"jest": "^22.4.3",
"npm-watch": "^0.3.0",
"nps": "^5.9.0",

@@ -30,0 +38,0 @@ "nps-utils": "^1.5.0",

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