File tree 3 files changed +43
-8
lines changed
3 files changed +43
-8
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,12 @@ export default class IndexController extends Controller {
11
11
12
12
maxIntersections = 5 ;
13
13
14
+ @tracked
15
+ isObserving = true ;
16
+
17
+ @tracked
18
+ numIntersectionsWithIsObserving = 0 ;
19
+
14
20
@tracked
15
21
shouldScrollIntoView = false ;
16
22
@@ -24,6 +30,16 @@ export default class IndexController extends Controller {
24
30
this . numIntersectionsWithMaxEnter ++ ;
25
31
}
26
32
33
+ @action
34
+ toggleIsObserving ( ) {
35
+ this . isObserving = ! this . isObserving ;
36
+ }
37
+
38
+ @action
39
+ onEnteringWithIsObserving ( ) {
40
+ this . numIntersectionsWithIsObserving ++ ;
41
+ }
42
+
27
43
@action
28
44
onScrollIntoViewTrigger ( ) {
29
45
this . shouldScrollIntoView = true ;
Original file line number Diff line number Diff line change 9
9
}
10
10
}
11
11
12
+ .action-button {
13
+ border-radius : 4px ;
14
+ padding : 0.5em ;
15
+ background-color : orangered ;
16
+ color : white ;
17
+ }
18
+
12
19
.scroll-into-view {
13
20
border : 1px dotted black ;
14
21
padding : 50px 16px ;
15
22
text-align : center ;
16
-
17
- button {
18
- border-radius : 4px ;
19
- padding : .5em ;
20
- background-color : orangered ;
21
- color : white ;
22
- }
23
23
}
24
24
25
25
// prevent copy button from overlapping code
Original file line number Diff line number Diff line change 24
24
</demo .example>
25
25
{{ demo.snippet " did-intersect-with-max-enter.hbs" label =" example with max enter.hbs" }}
26
26
27
+ <demo .example @name =" did-intersect-with-is-observing.hbs" >
28
+ <div
29
+ class =" intersection-box"
30
+ {{ did-intersect
31
+ isObserving =this.isObserving
32
+ onEnter =this.onEnteringWithIsObserving
33
+ }}
34
+ >
35
+ <p >Number of times this box has intersected the screen: {{ this.numIntersectionsWithIsObserving }} </p >
36
+
37
+ <p >isObserving: {{ this.isObserving }} </p >
38
+
39
+ <button type =' button' class =" action-button" {{ on " click" this.toggleIsObserving }} >
40
+ {{ if this.isObserving " Stop" " Start" }} observing
41
+ </button >
42
+ </div >
43
+ </demo .example>
44
+ {{ demo.snippet " did-intersect-with-is-observing.hbs" label =" example with isObserving.hbs" }}
45
+
27
46
<demo .example @name =" scroll-into-view.hbs" >
28
47
<div
29
48
class =" scroll-into-view"
30
49
{{ scroll-into-view shouldScroll =this.shouldScrollIntoView }}
31
50
>
32
- <button type =" button" class =" scroll-into-view__button " {{ on " click" this.onScrollIntoViewTrigger }} >
51
+ <button type =" button" class =" action-button " {{ on " click" this.onScrollIntoViewTrigger }} >
33
52
Trigger Scroll-into-view on click
34
53
</button >
35
54
</div >
You can’t perform that action at this time.
0 commit comments