electron-retain-webview-scroll
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -22,3 +22,3 @@ /** | ||
ScrollTracker.prototype.forward = function() { | ||
ScrollTracker.prototype.forward = function () { | ||
this.index += 1; | ||
@@ -31,3 +31,3 @@ if (this.index >= this.details.length) { | ||
ScrollTracker.prototype.back = function() { | ||
ScrollTracker.prototype.back = function () { | ||
if (this.index > 0) this.index -= 1; | ||
@@ -37,9 +37,11 @@ this.motion = NAVTYPE.BACK; | ||
ScrollTracker.prototype.reload = function() { | ||
ScrollTracker.prototype.reload = function () { | ||
this.motion = NAVTYPE.RELOAD; | ||
}; | ||
ScrollTracker.prototype.setScrollPosition = function(position) { | ||
ScrollTracker.prototype.setScrollPosition = function (position) { | ||
try { | ||
this.details[this.index].position = position; | ||
if (this.index >= 0 && this.details[this.index]) { | ||
this.details[this.index].position = position; | ||
} | ||
} catch (e) { | ||
@@ -50,5 +52,6 @@ throw Error(`Unable to set scroll position:\n${e}`); | ||
ScrollTracker.prototype.getScrollPosition = function() { | ||
ScrollTracker.prototype.getScrollPosition = function () { | ||
try { | ||
let position = this.details[this.index].position; | ||
let position = | ||
this.details[this.index] && this.details[this.index].position; | ||
return position ? position : { x: 0, y: 0 }; | ||
@@ -61,3 +64,3 @@ } catch (e) { | ||
ScrollTracker.prototype.didNavigate = function(url) { | ||
ScrollTracker.prototype.didNavigate = function (url) { | ||
if (this.motion === NAVTYPE.NEW_PAGE) { | ||
@@ -72,3 +75,3 @@ this.index += 1; | ||
ScrollTracker.prototype.didScroll = function(position) { | ||
ScrollTracker.prototype.didScroll = function (position) { | ||
this.setScrollPosition(position); | ||
@@ -75,0 +78,0 @@ }; |
{ | ||
"name": "electron-retain-webview-scroll", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Manage scrolling of content inside an Electron webview element.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
10482
219