@@ -5,6 +5,10 @@ import styled from "react-emotion"
5
5
import EcosystemSection from "./ecosystem-section"
6
6
7
7
import presets from "../../utils/presets"
8
+ import {
9
+ setupScrollersObserver ,
10
+ unobserveScrollers ,
11
+ } from "../../utils/scrollers-observer"
8
12
9
13
const EcosystemBoardRoot = styled ( `div` ) `
10
14
display: flex;
@@ -21,68 +25,12 @@ const EcosystemBoardRoot = styled(`div`)`
21
25
`
22
26
23
27
class EcosystemBoard extends Component {
24
- observer
25
- observerTargets = [ ]
26
-
27
28
componentDidMount ( ) {
28
- if ( typeof window . IntersectionObserver !== `undefined` ) {
29
- this . setupObserver ( )
30
- }
29
+ setupScrollersObserver ( )
31
30
}
32
31
33
32
componentWillUnmount ( ) {
34
- if ( typeof window . IntersectionObserver !== `undefined` ) {
35
- this . observerTargets . forEach ( target => this . observer . unobserve ( target ) )
36
- }
37
- }
38
-
39
- setupObserver = ( ) => {
40
- const options = { rootMargin : `0px` , threshold : [ 1 ] }
41
- this . observer = new IntersectionObserver ( this . handleIntersect , options )
42
- this . observerTargets = Array . from (
43
- document . querySelectorAll ( `.featuredItems` )
44
- )
45
-
46
- this . observerTargets . forEach ( target => this . observer . observe ( target ) )
47
- }
48
-
49
- handleIntersect = ( entries , observer ) => {
50
- entries . forEach ( entry => {
51
- const target = entry . target
52
-
53
- if ( entry . intersectionRatio > 0 ) {
54
- setTimeout (
55
- ( ) => this . turnOnLeadScroll ( { target, duration : 1000 , distance : 20 } ) ,
56
- 250
57
- )
58
- this . observer . unobserve ( target )
59
- }
60
- } )
61
- }
62
-
63
- turnOnLeadScroll = ( { target, duration, distance } ) => {
64
- let startTime = null
65
-
66
- function animation ( currentTime ) {
67
- if ( startTime === null ) {
68
- startTime = currentTime
69
- }
70
-
71
- const timeElapsed = currentTime - startTime
72
- const getDistanceToScroll = ease ( timeElapsed , 0 , distance , duration )
73
-
74
- target . scroll ( { top : 0 , left : getDistanceToScroll } )
75
-
76
- if ( timeElapsed < duration ) {
77
- requestAnimationFrame ( animation )
78
- }
79
- }
80
-
81
- function ease ( t , b , c , d ) {
82
- return - c * ( t /= d ) * ( t - 2 ) + b
83
- }
84
-
85
- requestAnimationFrame ( animation )
33
+ unobserveScrollers ( )
86
34
}
87
35
88
36
render ( ) {
@@ -102,11 +50,11 @@ class EcosystemBoard extends Component {
102
50
links = { [
103
51
{ label : `Browse Plugins` , to : `/plugins/` } ,
104
52
{
105
- label : `Plugin Authoring ` ,
53
+ label : `Creating Plugins ` ,
106
54
to : `/docs/plugin-authoring/` ,
107
55
secondary : true ,
108
56
} ,
109
- { label : `Plugin Docs ` , to : `/docs/plugins/` , secondary : true } ,
57
+ { label : `Using Plugins ` , to : `/docs/plugins/` , secondary : true } ,
110
58
] }
111
59
featuredItems = { plugins }
112
60
/>
@@ -117,7 +65,7 @@ class EcosystemBoard extends Component {
117
65
icon = { StartersIcon }
118
66
links = { [
119
67
{ label : `Browse Starters` , to : `/starters/` } ,
120
- { label : `Starter Docs ` , to : `/docs/starters/` , secondary : true } ,
68
+ { label : `Using Starters ` , to : `/docs/starters/` , secondary : true } ,
121
69
] }
122
70
featuredItems = { starters }
123
71
/>
0 commit comments