react-scroll
Advanced tools
Comparing version 0.30.0 to 0.31.0
@@ -6,2 +6,3 @@ exports.Link = require('./components/Link.js'); | ||
exports.scroller = require('./mixins/scroller.js'); | ||
exports.Events = require('./mixins/scroll-events.js'); | ||
exports.scrollSpy = require('./mixins/scroll-spy.js'); |
@@ -7,2 +7,4 @@ var smooth = require('./smooth'); | ||
var events = require('./scroll-events'); | ||
/* | ||
@@ -43,2 +45,4 @@ * Sets the cancel trigger | ||
var __target; | ||
var __to; | ||
var __start; | ||
@@ -76,7 +80,12 @@ var __deltaTop; | ||
requestAnimationFrame(animateTopScroll); | ||
return; | ||
} | ||
if(events.registered['end']) { | ||
events.registered['end'](__to, __target); | ||
} | ||
}; | ||
var startAnimateTopScroll = function(y, options) { | ||
var startAnimateTopScroll = function(y, options, to, target) { | ||
__start = null; | ||
@@ -87,2 +96,4 @@ __cancel = false; | ||
__duration = options.duration || 1000; | ||
__to = to; | ||
__target = target; | ||
@@ -89,0 +100,0 @@ requestAnimationFrame(animateTopScroll); |
@@ -10,3 +10,3 @@ "use strict"; | ||
var Helpers = { | ||
Scroll: { | ||
@@ -13,0 +13,0 @@ |
var animateScroll = require('./animate-scroll'); | ||
var events = require('./scroll-events'); | ||
@@ -9,3 +10,3 @@ var __mapped = {}; | ||
unmount: function() { | ||
__mapped = []; | ||
__mapped = {}; | ||
}, | ||
@@ -47,2 +48,5 @@ | ||
if(events.registered['begin']) { | ||
events.registered['begin'](to, target); | ||
} | ||
/* | ||
@@ -66,4 +70,5 @@ * if animate is not provided just scroll into the view | ||
}; | ||
animateScroll.animateTopScroll(coordinates.top + (offset || 0), options); | ||
animateScroll.animateTopScroll(coordinates.top + (offset || 0), options, target, to); | ||
@@ -70,0 +75,0 @@ } |
{ | ||
"name": "react-scroll", | ||
"version": "0.30.0", | ||
"version": "0.31.0", | ||
"description": "A scroll component for React.js", | ||
@@ -5,0 +5,0 @@ "main": "lib", |
## React Scroll | ||
Directive for basic scrolling and smooth scrolling. | ||
I love contributions, just make sure your test passes. | ||
I've started writing the tests for all the elements, contribute if you'd like to learn it. | ||
I love contributions, just make sure your test passes. | ||
@@ -35,7 +34,25 @@ ### Install | ||
var Events = Scroll.Events; | ||
var Section = React.createClass({ | ||
mixins: [Events], | ||
componentDidMount: function() { | ||
this.scrollEvent.register('begin', function(to, element) { | ||
console.log("begin", arguments); | ||
}); | ||
this.scrollEvent.register('end', function(to, element) { | ||
console.log("end", arguments); | ||
}); | ||
}, | ||
componentWillUnmount: function() { | ||
this.scrollEvent.remove('begin'); | ||
this.scrollEvent.remove('end'); | ||
}, | ||
render: function () { | ||
return ( | ||
<Link to="test1" spy={true} smooth={true} offset={50} duration={500} >Test 1</Link> | ||
<Button className="btn" type="submit" value="Test 2" to="test2" spy={true} smooth={true} offset={50} duration={500} >Test 2</Button> | ||
<Button className="btn" type="submit" value="Test 2" to="test2" spy={true} smooth={true} offset={50} duration={500} >Test 2</Button> | ||
@@ -60,2 +77,29 @@ <Element name="test1" className="element"> | ||
#### Scroll events | ||
```js | ||
var Scroll = require('react-scroll'); | ||
var Events = Scroll.Events; | ||
> Register events | ||
>> begin - start of the scrolling | ||
Events.scrollEvent.register('begin', function(to, element) { | ||
console.log("begin", to, element); | ||
}); | ||
>> end - end of the scrolling/animation | ||
Events.scrollEvent.register('end', function(to, element) { | ||
console.log("end", to, element); | ||
}); | ||
> Remove events | ||
Events.scrollEvent.remove('begin'); | ||
Events.scrollEvent.remove('end'); | ||
``` | ||
#### Create your own Link/Element | ||
@@ -91,2 +135,2 @@ > Simply just include the mixins! | ||
``` | ||
``` |
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
18897
16
484
134