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

@expressen/tallahassee

Package Overview
Dependencies
Maintainers
4
Versions
207
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@expressen/tallahassee - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

46

index.js

@@ -28,3 +28,4 @@ "use strict";

function load(resp) {
let pending;
let pending, currentPageYOffset;
let elementsToScroll = () => {};

@@ -39,5 +40,8 @@ compile();

const browserContext = {
$: document.$,
document,
setElementsToScroll,
scrollToBottomOfElement,
scrollToTopOfElement,
window,
document,
$: document.$,
};

@@ -53,3 +57,6 @@

currentPageYOffset = window.pageYOffset;
document.addEventListener("submit", onDocumentSubmit);
window.addEventListener("scroll", onWindowScroll);

@@ -79,2 +86,35 @@ return browserContext;

}
function setElementsToScroll(elmsToScrollFn) {
elementsToScroll = elmsToScrollFn;
}
function onWindowScroll() {
if (!elementsToScroll) return;
const elms = elementsToScroll(document);
if (!elms || !elms.length) return;
const pageYOffset = window.pageYOffset;
const delta = currentPageYOffset - pageYOffset;
elms.slice().forEach((elm) => {
const {top} = elm.getBoundingClientRect();
elm._setBoundingClientRect((top || 0) + delta);
});
currentPageYOffset = pageYOffset;
}
function scrollToTopOfElement(element, offset = 0) {
const {top} = element.getBoundingClientRect();
const pageYOffset = window.pageYOffset;
window.scroll(0, pageYOffset + top - offset);
}
function scrollToBottomOfElement(element, offset = 0) {
const {height} = element.getBoundingClientRect();
const offsetFromBottom = window.innerHeight - height;
return scrollToTopOfElement(element, offsetFromBottom + offset);
}
}

@@ -81,0 +121,0 @@ }

@@ -158,2 +158,6 @@ "use strict";

Object.defineProperty(element, "offsetHeight", {
get: () => getBoundingClientRect().height
});
if (tagName === "form") {

@@ -160,0 +164,0 @@ element.submit = submit;

@@ -7,5 +7,7 @@ "use strict";

module.exports = function Window(resp, windowObjects, innerWidth = 760, innerHeight = 760) {
const emitter = new EventEmitter();
const location = getLocation(resp.request);
const emitter = new EventEmitter();
let pageYOffset = 0;
const window = Object.assign({

@@ -23,6 +25,10 @@ _resize: resizeWindow,

removeEventListener,
scroll: dispatchEvent.bind(null, "scroll"),
scroll,
setTimeout: (fn, ms, ...args) => fn(...args),
}, windowObjects);
Object.defineProperty(window, "pageYOffset", {
get: () => pageYOffset
});
return window;

@@ -46,2 +52,7 @@

function scroll(xCoord, yCoord) {
if (yCoord !== undefined) pageYOffset = yCoord;
dispatchEvent("scroll");
}
function resizeWindow(newInnerWidth, newInnerHeight) {

@@ -48,0 +59,0 @@ if (newInnerWidth !== undefined) {

2

package.json
{
"name": "@expressen/tallahassee",
"version": "0.4.1",
"version": "0.4.2",
"description": "Expressen client testing framework",

@@ -5,0 +5,0 @@ "main": "index.js",

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