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

react-router-scroll-memory

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-router-scroll-memory - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

2

dist/ScrollMemory.min.js

@@ -1,1 +0,1 @@

"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var React=_interopDefault(require("react")),reactRouterDom=require("react-router-dom"),getPage=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1],o=e.map(function(e){return e.pathname}).indexOf(t);return-1<o?e[o]:void 0},getIndexPage=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];return e.map(function(e){return e.pathname}).indexOf(t)},saveUrl=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,n=Array.isArray(e)?e:[],r=getIndexPage(n,t);return-1<r?n[r].scroll=o:n.push({pathname:t,scroll:o}),n},getScrollPage=function(){var e=0;return document.documentElement&&null!==document.documentElement&&(e=document.documentElement.scrollTop),window.pageYOffset||e},getScrollElement=function(e){var t=0,o=document.getElementById(e);return null!==o&&(t=o.scrollTop),t},scrollTo=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;return window.requestAnimationFrame(function(){window.scrollTo(0,e)})},scrollToElement=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,t=arguments[1],o=document.getElementById(t);o&&o.scroll({top:e})},isBrowser=function(){return"undefined"!=typeof window};function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var ScrollMemory=function(o){function n(e){_classCallCheck(this,n);var t=_possibleConstructorReturn(this,o.call(this,e));return t.detectPop=t.detectPop.bind(t),t.url=[],t.requestID=0,t}return _inherits(n,o),n.prototype.componentDidMount=function(){isBrowser()&&window.addEventListener("popstate",this.detectPop)},n.prototype.componentWillReceiveProps=function(e){if(isBrowser()){var t=this.props.location,o=e.location,n=(o.pathname!==t.pathname||o.search!==t.search)&&""===o.hash,r=this.props.elementID?getScrollElement(this.props.elementID):getScrollPage();if(n){this.requestID=this.props.elementID?scrollToElement(0,this.props.elementID):scrollTo(0);var l=""+t.pathname+t.search+t.hash;this.url=saveUrl(this.url,l,r)}}},n.prototype.componentWillUnmount=function(){isBrowser()&&window.removeEventListener("popstate",this.detectPop)},n.prototype.detectPop=function(){if(isBrowser()){var e=window.location.pathname,t=getPage(this.url,e);0<this.requestID&&(window.cancelAnimationFrame(this.requestID),this.requestID=0),t&&(this.props.elementID?scrollToElement(t.scroll,this.props.elementID):scrollTo(t.scroll))}},n.prototype.render=function(){return null},n}(React.Component),ScrollMemory$1=reactRouterDom.withRouter(ScrollMemory);module.exports=ScrollMemory$1;
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var React=_interopDefault(require("react")),reactRouterDom=require("react-router-dom"),getPage=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1],o=e.map(function(e){return e.pathname}).indexOf(t);return-1<o?e[o]:void 0},getIndexPage=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];return e.map(function(e){return e.pathname}).indexOf(t)},saveUrl=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,n=Array.isArray(e)?e:[],r=getIndexPage(n,t);return-1<r?n[r].scroll=o:n.push({pathname:t,scroll:o}),n},getScrollPage=function(){var e=0;return document.documentElement&&null!==document.documentElement&&(e=document.documentElement.scrollTop),window.pageYOffset||e},getScrollElement=function(e){var t=0,o=document.getElementById(e);return null!==o&&(t=o.scrollTop),t},scrollTo=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;return window.requestAnimationFrame(function(){window.scrollTo(0,e)})},scrollToElement=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,t=arguments[1],o=document.getElementById(t);o&&(o.scrollTop=e)},isBrowser=function(){return"undefined"!=typeof window};function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var ScrollMemory=function(o){function n(e){_classCallCheck(this,n);var t=_possibleConstructorReturn(this,o.call(this,e));return t.detectPop=t.detectPop.bind(t),t.url=[],t.requestID=0,t}return _inherits(n,o),n.prototype.componentDidMount=function(){isBrowser()&&window.addEventListener("popstate",this.detectPop)},n.prototype.componentWillReceiveProps=function(e){if(isBrowser()){var t=this.props.location,o=e.location,n=(o.pathname!==t.pathname||o.search!==t.search)&&""===o.hash,r=this.props.elementID?getScrollElement(this.props.elementID):getScrollPage();if(n){this.requestID=this.props.elementID?scrollToElement(0,this.props.elementID):scrollTo(0);var l=""+t.pathname+t.search+t.hash;this.url=saveUrl(this.url,l,r)}}},n.prototype.componentWillUnmount=function(){isBrowser()&&window.removeEventListener("popstate",this.detectPop)},n.prototype.detectPop=function(){if(isBrowser()){var e=window.location.pathname,t=getPage(this.url,e);0<this.requestID&&(window.cancelAnimationFrame(this.requestID),this.requestID=0),t&&(this.props.elementID?scrollToElement(t.scroll,this.props.elementID):scrollTo(t.scroll))}},n.prototype.render=function(){return null},n}(React.Component),ScrollMemory$1=reactRouterDom.withRouter(ScrollMemory);module.exports=ScrollMemory$1;
{
"name": "react-router-scroll-memory",
"version": "1.0.3",
"version": "1.0.4",
"description": "For React Router V4. React component to keep the scroll of the page and to restore it if the user clicks on the previous button of its browser",

@@ -5,0 +5,0 @@ "main": "./dist/ScrollMemory.min.js",

@@ -77,3 +77,3 @@ // @flow

/**
/**
* scroll to y number inside an element

@@ -86,7 +86,5 @@ * @param {number} scrollnumber

if (element) {
element.scroll({
top: scrollnumber,
});
element.scrollTop = scrollnumber;
}
}
};

@@ -93,0 +91,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