react-scroll
Advanced tools
Comparing version 0.12.0 to 0.13.0
@@ -21,3 +21,3 @@ "use strict"; | ||
* Spy helper | ||
*/ | ||
*/ | ||
@@ -33,8 +33,8 @@ var spyCallbacks = []; | ||
/* | ||
/* | ||
* Helper function to never extend 60fps on the webpage. | ||
*/ | ||
*/ | ||
var requestAnimationFrame = (function () { | ||
return window.requestAnimationFrame || | ||
window.webkitRequestAnimationFrame || | ||
return window.requestAnimationFrame || | ||
window.webkitRequestAnimationFrame || | ||
function (callback, element, delay) { | ||
@@ -61,3 +61,3 @@ window.setTimeout(callback, delay || (1000/60)); | ||
var isCSS1Compat = ((document.compatMode || "") === "CSS1Compat"); | ||
return supportPageOffset ? window.pageYOffset : isCSS1Compat ? | ||
return supportPageOffset ? window.pageYOffset : isCSS1Compat ? | ||
document.documentElement.scrollTop : document.body.scrollTop; | ||
@@ -106,4 +106,7 @@ }; | ||
}, | ||
getDefaultProps: function() { | ||
return {offset: 0}; | ||
}, | ||
scrollTo : function(to) { | ||
/* | ||
@@ -114,3 +117,3 @@ * get the mapped DOM element | ||
var target = __mapped[to]; | ||
if(!target) { | ||
@@ -126,3 +129,3 @@ throw new Error("target Element not found"); | ||
if(!this.props.smooth) { | ||
if(!this.props.smooth) { | ||
window.scrollTo(0, cordinates.top); | ||
@@ -135,16 +138,16 @@ return; | ||
*/ | ||
var options = { | ||
duration : this.props.duration | ||
var options = { | ||
duration : this.props.duration | ||
}; | ||
startAnimateTopScroll(cordinates.top, options); | ||
startAnimateTopScroll(cordinates.top + this.props.offset, options); | ||
}, | ||
onClick: function() { | ||
/* | ||
* give the posibility to override onClick | ||
*/ | ||
if(this.props.onClick) { | ||
@@ -184,4 +187,4 @@ this.props.onClick(event); | ||
if(!element) { | ||
element = __mapped[to]; | ||
if(!element) { | ||
element = __mapped[to]; | ||
var cords = element.getBoundingClientRect(); | ||
@@ -193,3 +196,3 @@ top = (cords.top + y); | ||
if(y >= top && y <= height && __activeLink != to) { | ||
__activeLink = to; | ||
@@ -200,3 +203,3 @@ | ||
var length = spySetState.length; | ||
for(var i = 0; i < length; i = i + 1) { | ||
@@ -217,2 +220,5 @@ spySetState[i](); | ||
__mapped[this.props.name] = this.getDOMNode(); | ||
}, | ||
componentWillUnmount: function() { | ||
delete __mapped[this.props.name]; | ||
} | ||
@@ -219,0 +225,0 @@ } |
{ | ||
"name": "react-scroll", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "A scroll component for React.js", | ||
@@ -5,0 +5,0 @@ "main": "lib", |
@@ -36,4 +36,4 @@ ## React Scroll | ||
return ( | ||
<Link to="test1" spy={true} smooth={true} duration={500} >Test 1</Link> | ||
<Link to="test2" spy={true} smooth={true} duration={500} >Test 2</Link> | ||
<Link to="test1" spy={true} smooth={true} offset={50} duration={500} >Test 1</Link> | ||
<Link to="test2" spy={true} smooth={true} offset={50} duration={500} >Test 2</Link> | ||
@@ -40,0 +40,0 @@ <Element name="test1" className="element"> |
8820
219