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

electron-retain-webview-scroll

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-retain-webview-scroll - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

0

CHANGELOG.md

@@ -0,0 +0,0 @@ # Changelog

54

index.js

@@ -13,3 +13,3 @@ "use strict";

// TODO: Allow array of selectors, allow element or array of elements
Scroller.prototype.add = function(selector) {
Scroller.prototype.add = function (selector) {
let self = this;

@@ -29,9 +29,21 @@ selector = selector || "webview";

const scrollToLastPosition = () => {
let position = tracker.getScrollPosition();
webview.send(EVENTS.SCROLL_TO, position);
tracker.motion = NAVTYPE.NEW_PAGE;
};
// Set up webview event listeners
webview.addEventListener("ipc-message", function(e) {
webview.addEventListener("ipc-message", function (e) {
if (e.channel === EVENTS.DID_SCROLL) {
self.didScroll.call(self, selector, e.args[0].position);
}
if (e.channel === EVENTS.REQUEST_SCROLL) {
if (tracker.motion === NAVTYPE.NEW_PAGE) {
tracker.index -= 1;
scrollToLastPosition();
}
}
});
webview.addEventListener("did-navigate", function() {
webview.addEventListener("did-navigate", function () {
self.didNavigate.call(self, selector);

@@ -42,7 +54,6 @@ });

//})
webview.addEventListener("did-finish-load", function() {
webview.addEventListener("did-finish-load", function () {
if (tracker.motion !== NAVTYPE.NEW_PAGE) {
let position = tracker.getScrollPosition();
webview.send(EVENTS.SCROLL_TO, position);
tracker.motion = NAVTYPE.NEW_PAGE;
scrollToLastPosition();
}

@@ -53,3 +64,3 @@ });

tracker.webviewGoBack = webview.goBack;
webview.goBack = function() {
webview.goBack = function () {
tracker.back();

@@ -60,3 +71,3 @@ tracker.webviewGoBack.call(webview);

tracker.webviewGoForward = webview.goForward;
webview.goForward = function() {
webview.goForward = function () {
tracker.forward();

@@ -67,3 +78,3 @@ tracker.webviewGoForward.call(webview);

tracker.webviewReload = webview.reload;
webview.reload = function() {
webview.reload = function () {
tracker.reload();

@@ -88,7 +99,7 @@ tracker.webviewReload.call(webview);

//
Scroller.prototype.didScroll = function(selector, position) {
Scroller.prototype.didScroll = function (selector, position) {
this.trackers.get(selector).didScroll(position);
};
Scroller.prototype.didNavigate = function(selector) {
Scroller.prototype.didNavigate = function (selector) {
let webview = document.querySelector(selector);

@@ -102,15 +113,22 @@ let tracker = this.trackers.get(selector);

//
Scroller.prototype.preload = function() {
document.addEventListener("DOMContentLoaded", function() {
window.addEventListener("scroll", function(event) {
Scroller.prototype.preload = function () {
document.addEventListener("DOMContentLoaded", function () {
if (performance.navigation.type === 1) {
ipcRenderer.sendToHost(EVENTS.REQUEST_SCROLL);
}
window.addEventListener("scroll", function (event) {
ipcRenderer.sendToHost(EVENTS.DID_SCROLL, {
position: {
x: window.scrollX,
y: window.scrollY
}
y: window.scrollY,
},
});
});
});
ipcRenderer.on(EVENTS.SCROLL_TO, function(event, position) {
ipcRenderer.on(EVENTS.SCROLL_TO, function (event, position) {
window.sizzyRestoringScroll = true;
window.scrollTo(position.x, position.y);
setTimeout(() => {
window.sizzyRestoringScroll = false;
}, 200);
ipcRenderer.sendToHost(EVENTS.DID_SCROLL_TO, { position: position });

@@ -117,0 +135,0 @@ });

@@ -0,0 +0,0 @@ module.exports = Object.freeze({

@@ -0,0 +0,0 @@ /**

{
"name": "electron-retain-webview-scroll",
"version": "1.0.1",
"version": "1.0.2",
"description": "Manage scrolling of content inside an Electron webview element.",

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

@@ -0,0 +0,0 @@ # Electron Scroller

Sorry, the diff of this file is not supported yet

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