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

react-scroll-into-view-if-needed

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-scroll-into-view-if-needed - npm Package Compare versions

Comparing version 2.1.7 to 3.0.0

babel.config.js

275

dist/es/index.js

@@ -1,6 +0,145 @@

import { createElement, createRef, PureComponent } from 'react';
import { createRef, createElement, PureComponent } from 'react';
import PropTypes from 'prop-types';
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
function _objectWithoutProperties(source, excluded) {
if (source == null) return {};
var target = _objectWithoutPropertiesLoose(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
function isElement(el) {
return el != null && typeof el === 'object' && (el.nodeType === 1 || el.nodeType === 11);
return el != null && typeof el === 'object' && el.nodeType === 1;
}

@@ -30,3 +169,3 @@

if (elementEdgeStart < scrollingEdgeStart && elementSize < scrollingSize || elementEdgeEnd > scrollingEdgeEnd && elementSize > scrollingSize) {
if (elementEdgeStart <= scrollingEdgeStart && elementSize <= scrollingSize || elementEdgeEnd >= scrollingEdgeEnd && elementSize >= scrollingSize) {
return elementEdgeStart - scrollingEdgeStart - scrollingBorderStart;

@@ -61,3 +200,3 @@ }

while (isElement(cursor) && checkBoundary(cursor)) {
cursor = cursor.parentNode || cursor.host;
cursor = cursor.parentNode;

@@ -229,6 +368,12 @@ if (cursor === scrollingElement) {

function scrollIntoView(target, options) {
var targetIsDetached = !target.ownerDocument.documentElement.contains(target);
if (isOptionsObject(options) && typeof options.behavior === 'function') {
return options.behavior(compute(target, options));
return options.behavior(targetIsDetached ? [] : compute(target, options));
}
if (targetIsDetached) {
return;
}
var computeOptions = getOptions(options);

@@ -238,90 +383,19 @@ return defaultBehavior(compute(target, computeOptions), computeOptions.behavior);

var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var ScrollIntoViewIfNeeded =
/*#__PURE__*/
function (_PureComponent) {
_inherits(ScrollIntoViewIfNeeded, _PureComponent);
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function ScrollIntoViewIfNeeded() {
var _this;
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
_classCallCheck(this, ScrollIntoViewIfNeeded);
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
_this = _possibleConstructorReturn(this, _getPrototypeOf(ScrollIntoViewIfNeeded).call(this));
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
var objectWithoutProperties = function (obj, keys) {
var target = {};
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
}
return target;
};
var possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
var ScrollIntoViewIfNeeded = function (_PureComponent) {
inherits(ScrollIntoViewIfNeeded, _PureComponent);
function ScrollIntoViewIfNeeded() {
classCallCheck(this, ScrollIntoViewIfNeeded);
var _this = possibleConstructorReturn(this, (ScrollIntoViewIfNeeded.__proto__ || Object.getPrototypeOf(ScrollIntoViewIfNeeded)).call(this));
_this.handleScrollIntoViewIfNeeded = function () {
_defineProperty(_assertThisInitialized(_this), "handleScrollIntoViewIfNeeded", function () {
var options = _this.props.options;
var node = _this.node.current;
scrollIntoView(node, options);
};
});

@@ -332,4 +406,4 @@ _this.node = createRef();

createClass(ScrollIntoViewIfNeeded, [{
key: 'componentDidMount',
_createClass(ScrollIntoViewIfNeeded, [{
key: "componentDidMount",
value: function componentDidMount() {

@@ -343,3 +417,3 @@ var active = this.props.active;

}, {
key: 'componentDidUpdate',
key: "componentDidUpdate",
value: function componentDidUpdate(_ref) {

@@ -354,17 +428,19 @@ var active = _ref.active;

}, {
key: 'render',
key: "render",
value: function render() {
var _props = this.props,
active = _props.active,
elementType = _props.elementType,
children = _props.children,
options = _props.options,
wrapperProps = objectWithoutProperties(_props, ['active', 'elementType', 'children', 'options']);
var _this$props = this.props,
active = _this$props.active,
elementType = _this$props.elementType,
children = _this$props.children,
options = _this$props.options,
wrapperProps = _objectWithoutProperties(_this$props, ["active", "elementType", "children", "options"]);
return createElement(elementType, _extends({ ref: this.node }, wrapperProps), children);
return createElement(elementType, _objectSpread({
ref: this.node
}, wrapperProps), children);
}
}]);
return ScrollIntoViewIfNeeded;
}(PureComponent);
ScrollIntoViewIfNeeded.propTypes = {

@@ -380,4 +456,3 @@ active: PropTypes.bool,

scrollMode: PropTypes.oneOf(['always', 'if-needed']),
boundary: PropTypes.oneOfType([
// eslint-disable-next-line no-undef
boundary: PropTypes.oneOfType([// eslint-disable-next-line no-undef
PropTypes.instanceOf(Element), PropTypes.func]),

@@ -384,0 +459,0 @@ skipOverflowHiddenElements: PropTypes.bool

@@ -1,46 +0,64 @@

import { createElement, createRef, PureComponent } from 'react';
import { createRef, createElement, PureComponent } from 'react';
import PropTypes from 'prop-types';
import scrollIntoViewIfNeeded from 'scroll-into-view-if-needed';
var classCallCheck = function (instance, Constructor) {
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
}
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
var _extends = Object.assign || function (target) {
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
};
}
var inherits = function (subClass, superClass) {
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
throw new TypeError("Super expression must either be null or a function");
}

@@ -51,3 +69,2 @@

value: subClass,
enumerable: false,
writable: true,

@@ -57,39 +74,90 @@ configurable: true

});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
if (superClass) _setPrototypeOf(subClass, superClass);
}
var objectWithoutProperties = function (obj, keys) {
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
};
}
var possibleConstructorReturn = function (self, call) {
if (!self) {
function _objectWithoutProperties(source, excluded) {
if (source == null) return {};
var target = _objectWithoutPropertiesLoose(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
return self;
}
var ScrollIntoViewIfNeeded = function (_PureComponent) {
inherits(ScrollIntoViewIfNeeded, _PureComponent);
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
var ScrollIntoViewIfNeeded =
/*#__PURE__*/
function (_PureComponent) {
_inherits(ScrollIntoViewIfNeeded, _PureComponent);
function ScrollIntoViewIfNeeded() {
classCallCheck(this, ScrollIntoViewIfNeeded);
var _this;
var _this = possibleConstructorReturn(this, (ScrollIntoViewIfNeeded.__proto__ || Object.getPrototypeOf(ScrollIntoViewIfNeeded)).call(this));
_classCallCheck(this, ScrollIntoViewIfNeeded);
_this.handleScrollIntoViewIfNeeded = function () {
_this = _possibleConstructorReturn(this, _getPrototypeOf(ScrollIntoViewIfNeeded).call(this));
_defineProperty(_assertThisInitialized(_this), "handleScrollIntoViewIfNeeded", function () {
var options = _this.props.options;
var node = _this.node.current;
scrollIntoViewIfNeeded(node, options);
};
});

@@ -100,4 +168,4 @@ _this.node = createRef();

createClass(ScrollIntoViewIfNeeded, [{
key: 'componentDidMount',
_createClass(ScrollIntoViewIfNeeded, [{
key: "componentDidMount",
value: function componentDidMount() {

@@ -111,3 +179,3 @@ var active = this.props.active;

}, {
key: 'componentDidUpdate',
key: "componentDidUpdate",
value: function componentDidUpdate(_ref) {

@@ -122,17 +190,19 @@ var active = _ref.active;

}, {
key: 'render',
key: "render",
value: function render() {
var _props = this.props,
active = _props.active,
elementType = _props.elementType,
children = _props.children,
options = _props.options,
wrapperProps = objectWithoutProperties(_props, ['active', 'elementType', 'children', 'options']);
var _this$props = this.props,
active = _this$props.active,
elementType = _this$props.elementType,
children = _this$props.children,
options = _this$props.options,
wrapperProps = _objectWithoutProperties(_this$props, ["active", "elementType", "children", "options"]);
return createElement(elementType, _extends({ ref: this.node }, wrapperProps), children);
return createElement(elementType, _objectSpread({
ref: this.node
}, wrapperProps), children);
}
}]);
return ScrollIntoViewIfNeeded;
}(PureComponent);
ScrollIntoViewIfNeeded.propTypes = {

@@ -148,4 +218,3 @@ active: PropTypes.bool,

scrollMode: PropTypes.oneOf(['always', 'if-needed']),
boundary: PropTypes.oneOfType([
// eslint-disable-next-line no-undef
boundary: PropTypes.oneOfType([// eslint-disable-next-line no-undef
PropTypes.instanceOf(Element), PropTypes.func]),

@@ -152,0 +221,0 @@ skipOverflowHiddenElements: PropTypes.bool

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('prop-types')) :
typeof define === 'function' && define.amd ? define(['exports', 'react', 'prop-types'], factory) :
(factory((global['react-scroll-into-view-if-needed'] = {}),global.React,null));
}(this, (function (exports,react,PropTypes) { 'use strict';
(global = global || self, factory(global['react-scroll-into-view-if-needed'] = {}, global.React, global.PropTypes));
}(this, function (exports, react, PropTypes) { 'use strict';
PropTypes = PropTypes && PropTypes.hasOwnProperty('default') ? PropTypes['default'] : PropTypes;
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
function _objectWithoutProperties(source, excluded) {
if (source == null) return {};
var target = _objectWithoutPropertiesLoose(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
function isElement(el) {
return el != null && typeof el === 'object' && (el.nodeType === 1 || el.nodeType === 11);
return el != null && typeof el === 'object' && el.nodeType === 1;
}

@@ -35,3 +174,3 @@

if (elementEdgeStart < scrollingEdgeStart && elementSize < scrollingSize || elementEdgeEnd > scrollingEdgeEnd && elementSize > scrollingSize) {
if (elementEdgeStart <= scrollingEdgeStart && elementSize <= scrollingSize || elementEdgeEnd >= scrollingEdgeEnd && elementSize >= scrollingSize) {
return elementEdgeStart - scrollingEdgeStart - scrollingBorderStart;

@@ -66,3 +205,3 @@ }

while (isElement(cursor) && checkBoundary(cursor)) {
cursor = cursor.parentNode || cursor.host;
cursor = cursor.parentNode;

@@ -234,6 +373,12 @@ if (cursor === scrollingElement) {

function scrollIntoView(target, options) {
var targetIsDetached = !target.ownerDocument.documentElement.contains(target);
if (isOptionsObject(options) && typeof options.behavior === 'function') {
return options.behavior(compute(target, options));
return options.behavior(targetIsDetached ? [] : compute(target, options));
}
if (targetIsDetached) {
return;
}
var computeOptions = getOptions(options);

@@ -243,90 +388,19 @@ return defaultBehavior(compute(target, computeOptions), computeOptions.behavior);

var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var ScrollIntoViewIfNeeded =
/*#__PURE__*/
function (_PureComponent) {
_inherits(ScrollIntoViewIfNeeded, _PureComponent);
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function ScrollIntoViewIfNeeded() {
var _this;
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
_classCallCheck(this, ScrollIntoViewIfNeeded);
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
_this = _possibleConstructorReturn(this, _getPrototypeOf(ScrollIntoViewIfNeeded).call(this));
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
var objectWithoutProperties = function (obj, keys) {
var target = {};
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
}
return target;
};
var possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
var ScrollIntoViewIfNeeded = function (_PureComponent) {
inherits(ScrollIntoViewIfNeeded, _PureComponent);
function ScrollIntoViewIfNeeded() {
classCallCheck(this, ScrollIntoViewIfNeeded);
var _this = possibleConstructorReturn(this, (ScrollIntoViewIfNeeded.__proto__ || Object.getPrototypeOf(ScrollIntoViewIfNeeded)).call(this));
_this.handleScrollIntoViewIfNeeded = function () {
_defineProperty(_assertThisInitialized(_this), "handleScrollIntoViewIfNeeded", function () {
var options = _this.props.options;
var node = _this.node.current;
scrollIntoView(node, options);
};
});

@@ -337,4 +411,4 @@ _this.node = react.createRef();

createClass(ScrollIntoViewIfNeeded, [{
key: 'componentDidMount',
_createClass(ScrollIntoViewIfNeeded, [{
key: "componentDidMount",
value: function componentDidMount() {

@@ -348,3 +422,3 @@ var active = this.props.active;

}, {
key: 'componentDidUpdate',
key: "componentDidUpdate",
value: function componentDidUpdate(_ref) {

@@ -359,17 +433,19 @@ var active = _ref.active;

}, {
key: 'render',
key: "render",
value: function render() {
var _props = this.props,
active = _props.active,
elementType = _props.elementType,
children = _props.children,
options = _props.options,
wrapperProps = objectWithoutProperties(_props, ['active', 'elementType', 'children', 'options']);
var _this$props = this.props,
active = _this$props.active,
elementType = _this$props.elementType,
children = _this$props.children,
options = _this$props.options,
wrapperProps = _objectWithoutProperties(_this$props, ["active", "elementType", "children", "options"]);
return react.createElement(elementType, _extends({ ref: this.node }, wrapperProps), children);
return react.createElement(elementType, _objectSpread({
ref: this.node
}, wrapperProps), children);
}
}]);
return ScrollIntoViewIfNeeded;
}(react.PureComponent);
ScrollIntoViewIfNeeded.propTypes = {

@@ -385,4 +461,3 @@ active: PropTypes.bool,

scrollMode: PropTypes.oneOf(['always', 'if-needed']),
boundary: PropTypes.oneOfType([
// eslint-disable-next-line no-undef
boundary: PropTypes.oneOfType([// eslint-disable-next-line no-undef
PropTypes.instanceOf(Element), PropTypes.func]),

@@ -405,3 +480,3 @@ skipOverflowHiddenElements: PropTypes.bool

})));
}));
//# sourceMappingURL=index.js.map
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('prop-types'), require('scroll-into-view-if-needed')) :
typeof define === 'function' && define.amd ? define(['exports', 'react', 'prop-types', 'scroll-into-view-if-needed'], factory) :
(factory((global['react-scroll-into-view-if-needed'] = {}),global.React,null,null));
}(this, (function (exports,react,PropTypes,scrollIntoViewIfNeeded) { 'use strict';
(global = global || self, factory(global['react-scroll-into-view-if-needed'] = {}, global.React, global.PropTypes, global.scrollIntoViewIfNeeded));
}(this, function (exports, react, PropTypes, scrollIntoViewIfNeeded) { 'use strict';

@@ -10,43 +10,61 @@ PropTypes = PropTypes && PropTypes.hasOwnProperty('default') ? PropTypes['default'] : PropTypes;

var classCallCheck = function (instance, Constructor) {
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
}
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
var _extends = Object.assign || function (target) {
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
};
}
var inherits = function (subClass, superClass) {
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
throw new TypeError("Super expression must either be null or a function");
}

@@ -57,3 +75,2 @@

value: subClass,
enumerable: false,
writable: true,

@@ -63,39 +80,90 @@ configurable: true

});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
if (superClass) _setPrototypeOf(subClass, superClass);
}
var objectWithoutProperties = function (obj, keys) {
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
};
}
var possibleConstructorReturn = function (self, call) {
if (!self) {
function _objectWithoutProperties(source, excluded) {
if (source == null) return {};
var target = _objectWithoutPropertiesLoose(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
return self;
}
var ScrollIntoViewIfNeeded = function (_PureComponent) {
inherits(ScrollIntoViewIfNeeded, _PureComponent);
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
var ScrollIntoViewIfNeeded =
/*#__PURE__*/
function (_PureComponent) {
_inherits(ScrollIntoViewIfNeeded, _PureComponent);
function ScrollIntoViewIfNeeded() {
classCallCheck(this, ScrollIntoViewIfNeeded);
var _this;
var _this = possibleConstructorReturn(this, (ScrollIntoViewIfNeeded.__proto__ || Object.getPrototypeOf(ScrollIntoViewIfNeeded)).call(this));
_classCallCheck(this, ScrollIntoViewIfNeeded);
_this.handleScrollIntoViewIfNeeded = function () {
_this = _possibleConstructorReturn(this, _getPrototypeOf(ScrollIntoViewIfNeeded).call(this));
_defineProperty(_assertThisInitialized(_this), "handleScrollIntoViewIfNeeded", function () {
var options = _this.props.options;
var node = _this.node.current;
scrollIntoViewIfNeeded(node, options);
};
});

@@ -106,4 +174,4 @@ _this.node = react.createRef();

createClass(ScrollIntoViewIfNeeded, [{
key: 'componentDidMount',
_createClass(ScrollIntoViewIfNeeded, [{
key: "componentDidMount",
value: function componentDidMount() {

@@ -117,3 +185,3 @@ var active = this.props.active;

}, {
key: 'componentDidUpdate',
key: "componentDidUpdate",
value: function componentDidUpdate(_ref) {

@@ -128,17 +196,19 @@ var active = _ref.active;

}, {
key: 'render',
key: "render",
value: function render() {
var _props = this.props,
active = _props.active,
elementType = _props.elementType,
children = _props.children,
options = _props.options,
wrapperProps = objectWithoutProperties(_props, ['active', 'elementType', 'children', 'options']);
var _this$props = this.props,
active = _this$props.active,
elementType = _this$props.elementType,
children = _this$props.children,
options = _this$props.options,
wrapperProps = _objectWithoutProperties(_this$props, ["active", "elementType", "children", "options"]);
return react.createElement(elementType, _extends({ ref: this.node }, wrapperProps), children);
return react.createElement(elementType, _objectSpread({
ref: this.node
}, wrapperProps), children);
}
}]);
return ScrollIntoViewIfNeeded;
}(react.PureComponent);
ScrollIntoViewIfNeeded.propTypes = {

@@ -154,4 +224,3 @@ active: PropTypes.bool,

scrollMode: PropTypes.oneOf(['always', 'if-needed']),
boundary: PropTypes.oneOfType([
// eslint-disable-next-line no-undef
boundary: PropTypes.oneOfType([// eslint-disable-next-line no-undef
PropTypes.instanceOf(Element), PropTypes.func]),

@@ -174,3 +243,3 @@ skipOverflowHiddenElements: PropTypes.bool

})));
}));
//# sourceMappingURL=standalone.js.map

@@ -7,3 +7,3 @@ module.exports = {

'/coverage/',
'jest.setup.js'
'jest.setup.js',
],

@@ -19,2 +19,3 @@ coverageThreshold: {

setupFiles: ['./jest.setup.js'],
snapshotSerializers: ['enzyme-to-json/serializer']
};
const Enzyme = require('enzyme');
const Adapter = require('enzyme-adapter-react-16');
const Adapter = require('enzyme-adapter-react-17-updated');
Enzyme.configure({ adapter: new Adapter() });
{
"name": "react-scroll-into-view-if-needed",
"version": "2.1.7",
"version": "3.0.0",
"description": "A thin component wrapper around scroll-into-view-if-needed",

@@ -8,3 +8,4 @@ "main": "dist/umd/index.js",

"repository": "git@github.com:icd2k3/react-scroll-into-view-if-needed.git",
"author": "Justin Schrader <icd2k3@gmail.com>",
"author": "Justin Schrader <me@justin.beer>",
"license": "MIT",
"keywords": [

@@ -16,36 +17,2 @@ "react",

],
"license": "MIT",
"peerDependencies": {
"prop-types": "^15.6.1",
"react": "^16.0.0"
},
"dependencies": {},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.6",
"babel-jest": "^23.4.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"coveralls": "^3.0.2",
"cross-env": "^5.2.0",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"eslint": "^5.1.0",
"eslint-config-airbnb": "^17.0.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-jsx-a11y": "^6.1.0",
"eslint-plugin-react": "^7.10.0",
"jest": "^23.4.0",
"prop-types": "^15.6.2",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"rollup": "^0.62.0",
"rollup-plugin-babel": "^3.0.7",
"rollup-plugin-commonjs": "^9.1.3",
"rollup-plugin-node-resolve": "^3.3.0",
"scroll-into-view-if-needed": "^2.2.16"
},
"scripts": {

@@ -57,3 +24,43 @@ "build": "rollup -c && cross-env BUILD_TYPE=standalone rollup -c",

"travis": "yarn run lint && jest && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-push": "yarn lint && yarn test"
}
},
"peerDependencies": {
"prop-types": ">=15",
"react": ">=17"
},
"devDependencies": {
"@babel/cli": "^7.13.16",
"@babel/core": "^7.14.2",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/preset-env": "^7.14.2",
"@babel/preset-react": "^7.13.13",
"@commitlint/config-conventional": "^12.1.4",
"babel-eslint": "^10.0.1",
"commitlint": "^12.1.4",
"coveralls": "^3.1.0",
"cross-env": "^7.0.3",
"enzyme": "^3.11.0",
"enzyme-adapter-react-17-updated": "^1.0.2",
"enzyme-to-json": "^3.6.2",
"eslint": "^7.26.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.23.2",
"husky": "^6.0.0",
"jest": "^26.6.3",
"prop-types": "^15.7.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"rollup": "^2.47.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"scroll-into-view-if-needed": "^2.2.28"
}
}

@@ -11,3 +11,7 @@ import babel from 'rollup-plugin-babel';

.concat(IS_STANDALONE_BUILD ? 'scroll-into-view-if-needed' : []);
const globals = { react: 'React' };
const globals = {
react: 'React',
'prop-types': 'PropTypes',
'scroll-into-view-if-needed': 'scrollIntoViewIfNeeded',
};
const rootOutputProps = {

@@ -34,9 +38,4 @@ exports: 'named',

exclude: 'node_modules/**',
plugins: ['external-helpers'],
}),
resolve({
module: true,
jsnext: true,
main: true,
}),
resolve(),
commonjs(),

@@ -43,0 +42,0 @@ ],

@@ -7,50 +7,2 @@ import { createElement, createRef, PureComponent } from 'react';

export default class ScrollIntoViewIfNeeded extends PureComponent {
static propTypes = {
active: PropTypes.bool,
children: PropTypes.node.isRequired,
elementType: PropTypes.string,
// this shape should mirror the scroll-into-view-if-needed options
options: PropTypes.shape({
behavior: PropTypes.oneOfType([
PropTypes.oneOf([
'auto',
'smooth',
'instant',
]),
PropTypes.func,
]),
block: PropTypes.oneOf([
'center',
'end',
'nearest',
'start',
]),
inline: PropTypes.oneOf([
'center',
'end',
'nearest',
'start',
]),
scrollMode: PropTypes.oneOf([
'always',
'if-needed',
]),
boundary: PropTypes.oneOfType([
// eslint-disable-next-line no-undef
PropTypes.instanceOf(Element),
PropTypes.func,
]),
skipOverflowHiddenElements: PropTypes.bool,
}),
};
static defaultProps = {
active: true,
elementType: 'div',
options: {
behavior: 'smooth',
scrollMode: 'if-needed',
},
};
constructor() {

@@ -92,1 +44,48 @@ super();

}
ScrollIntoViewIfNeeded.propTypes = {
active: PropTypes.bool,
children: PropTypes.node.isRequired,
elementType: PropTypes.string,
// this shape should mirror the scroll-into-view-if-needed options
options: PropTypes.shape({
behavior: PropTypes.oneOfType([
PropTypes.oneOf([
'auto',
'smooth',
'instant',
]),
PropTypes.func,
]),
block: PropTypes.oneOf([
'center',
'end',
'nearest',
'start',
]),
inline: PropTypes.oneOf([
'center',
'end',
'nearest',
'start',
]),
scrollMode: PropTypes.oneOf([
'always',
'if-needed',
]),
boundary: PropTypes.oneOfType([
// eslint-disable-next-line no-undef
PropTypes.instanceOf(Element),
PropTypes.func,
]),
skipOverflowHiddenElements: PropTypes.bool,
}),
};
ScrollIntoViewIfNeeded.defaultProps = {
active: true,
elementType: 'div',
options: {
behavior: 'smooth',
scrollMode: 'if-needed',
},
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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