scroll-into-view-if-needed
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -1,8 +0,17 @@ | ||
# scroll-into-view-if-needed change log | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
The format is based on [Keep a Changelog](http://keepachangelog.com/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/). | ||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). | ||
## [Unreleased] | ||
## [1.2.0] - 2017-10-01 | ||
### Added | ||
* Set offset feature (#127 @iwangulenko) | ||
## [1.1.1] - 2017-10-01 | ||
### Fixed | ||
* Windows compatibility and CommonJS interop change back to Babel 5 functionality (#121 @khell) | ||
## [1.1.0] - 2017-03-29 | ||
@@ -54,3 +63,5 @@ ### Added | ||
[Unreleased]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.1.0...HEAD | ||
[Unreleased]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.2.0...HEAD | ||
[1.2.0]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.1.1...v1.2.0 | ||
[1.1.1]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.1.0...v1.1.1 | ||
[1.1.0]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.0.7...v1.1.0 | ||
@@ -57,0 +68,0 @@ [1.0.7]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.0.6...v1.0.7 |
@@ -213,3 +213,3 @@ 'use strict'; | ||
var index = function (elem, centerIfNeeded, options, finalElement) { | ||
var index = function (elem, centerIfNeeded, options, finalElement, config) { | ||
@@ -226,12 +226,17 @@ if (!elem) throw new Error('Element is required in scrollIntoViewIfNeeded') | ||
const offsetTop = config.offsetTop || 0; | ||
const offsetLeft = config.offsetLeft || 0; | ||
const offsetBottom = config.offsetBottom || 0; | ||
const offsetRight = config.offsetRight || 0; | ||
function makeArea(left, top, width, height) { | ||
return { "left": left, "top": top, "width": width, "height": height | ||
, "right": left + width, "bottom": top + height | ||
return { "left": left + offsetLeft, "top": top + offsetTop, "width": width, "height": height | ||
, "right": left + offsetLeft + width + offsetRight, "bottom": top + offsetTop + height + offsetBottom | ||
, "translate": | ||
function (x, y) { | ||
return makeArea(x + left, y + top, width, height); | ||
return makeArea(x + left + offsetLeft, y + top + offsetTop, width, height); | ||
} | ||
, "relativeFromTo": | ||
function (lhs, rhs) { | ||
var newLeft = left, newTop = top; | ||
var newLeft = left + offsetLeft, newTop = top + offsetTop; | ||
lhs = lhs.offsetParent; | ||
@@ -238,0 +243,0 @@ rhs = rhs.offsetParent; |
@@ -7,3 +7,3 @@ 'use strict'; | ||
exports.default = function (elem, centerIfNeeded, options, finalElement) { | ||
exports.default = function (elem, centerIfNeeded, options, finalElement, config) { | ||
@@ -20,11 +20,16 @@ if (!elem) throw new Error('Element is required in scrollIntoViewIfNeeded'); | ||
var offsetTop = config.offsetTop || 0; | ||
var offsetLeft = config.offsetLeft || 0; | ||
var offsetBottom = config.offsetBottom || 0; | ||
var offsetRight = config.offsetRight || 0; | ||
function makeArea(left, top, width, height) { | ||
return { "left": left, "top": top, "width": width, "height": height, | ||
"right": left + width, "bottom": top + height, | ||
return { "left": left + offsetLeft, "top": top + offsetTop, "width": width, "height": height, | ||
"right": left + offsetLeft + width + offsetRight, "bottom": top + offsetTop + height + offsetBottom, | ||
"translate": function translate(x, y) { | ||
return makeArea(x + left, y + top, width, height); | ||
return makeArea(x + left + offsetLeft, y + top + offsetTop, width, height); | ||
}, | ||
"relativeFromTo": function relativeFromTo(lhs, rhs) { | ||
var newLeft = left, | ||
newTop = top; | ||
var newLeft = left + offsetLeft, | ||
newTop = top + offsetTop; | ||
lhs = lhs.offsetParent; | ||
@@ -31,0 +36,0 @@ rhs = rhs.offsetParent; |
@@ -54,3 +54,3 @@ { | ||
}, | ||
"version": "1.1.1" | ||
"version": "1.2.0" | ||
} |
@@ -1,8 +0,3 @@ | ||
# scroll-into-view-if-needed | ||
# scroll-into-view-if-needed · [![CircleCI Status](https://img.shields.io/circleci/project/github/stipsan/scroll-into-view-if-needed.svg?style=flat-square)](https://circleci.com/gh/stipsan/scroll-into-view-if-needed) [![npm version](https://img.shields.io/npm/v/scroll-into-view-if-needed.svg?style=flat-square)](https://www.npmjs.com/package/scroll-into-view-if-needed) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release) | ||
[![npm package](https://img.shields.io/npm/dm/scroll-into-view-if-needed.svg)](https://www.npmjs.com/package/scroll-into-view-if-needed) | ||
[![NPM](https://nodei.co/npm/scroll-into-view-if-needed.png?downloadRank=true)](https://www.npmjs.com/package/scroll-into-view-if-needed) | ||
[![NPM](https://nodei.co/npm-dl/scroll-into-view-if-needed.png?months=3&height=2)](https://nodei.co/npm/scroll-into-view-if-needed/) | ||
This is a [ponyfill](https://ponyfill.com) with the added ability of animating the scroll itself. | ||
@@ -15,3 +10,3 @@ | ||
```bash | ||
npm install scroll-into-view-if-needed | ||
yarn add scroll-into-view-if-needed | ||
``` | ||
@@ -69,3 +64,3 @@ | ||
super(props) | ||
this.setSignupNode = (node) => { | ||
@@ -78,3 +73,3 @@ if(node) { | ||
event.preventDefault() | ||
// Passing the dom node from react is all you need for this to work | ||
@@ -81,0 +76,0 @@ scrollIntoViewIfNeeded(this._signupNode, false, { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
346
21485
10
91