Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
verona-modules-aspect
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IQB
verona-modules-aspect
Commits
fd48eb85
Commit
fd48eb85
authored
3 years ago
by
jojohoch
Browse files
Options
Downloads
Patches
Plain Diff
[player] Replace IntersectionService with IntersectionDetector class
parent
7f1184be
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
projects/player/src/app/classes/intersection-detector.ts
+7
-12
7 additions, 12 deletions
projects/player/src/app/classes/intersection-detector.ts
projects/player/src/app/services/unit-state.service.ts
+9
-5
9 additions, 5 deletions
projects/player/src/app/services/unit-state.service.ts
with
16 additions
and
17 deletions
projects/player/src/app/
servic
es/intersection
.service
.ts
→
projects/player/src/app/
class
es/intersection
-detector
.ts
+
7
−
12
View file @
fd48eb85
import
{
EventEmitter
,
Inject
,
Injectable
,
Output
}
from
'
@angular/core
'
;
import
{
DOCUMENT
}
from
'
@angular/common
'
;
import
{
EventEmitter
}
from
'
@angular/core
'
;
@
Injectable
({
providedIn
:
'
root
'
})
export
class
IntersectionService
{
export
class
IntersectionDetector
{
intersectionObserver
!
:
IntersectionObserver
;
elements
:
{
id
:
string
,
element
:
Element
}[]
=
[];
@
Output
()
intersecting
=
new
EventEmitter
<
string
>
();
root
!
:
Document
;
intersecting
=
new
EventEmitter
<
string
>
();
constructor
(@
Inject
(
DOCUMENT
)
private
document
:
Document
)
{
constructor
(
root
:
Document
)
{
this
.
root
=
root
;
this
.
initIntersectionObserver
();
}
...
...
@@ -24,7 +20,7 @@ export class IntersectionService {
}
});
},
{
root
:
documen
t
,
root
:
this
.
roo
t
,
rootMargin
:
'
0px 0px 0px 0px
'
}
);
...
...
@@ -39,7 +35,6 @@ export class IntersectionService {
const
intersectedElementIndex
=
this
.
elements
.
findIndex
(
e
=>
e
.
element
===
element
);
if
(
intersectedElementIndex
>
-
1
)
{
const
intersectedElement
=
this
.
elements
[
intersectedElementIndex
];
this
.
intersecting
.
emit
(
intersectedElement
.
id
);
this
.
intersectionObserver
.
unobserve
(
intersectedElement
.
element
);
this
.
elements
.
splice
(
intersectedElementIndex
,
1
);
}
...
...
This diff is collapsed.
Click to expand it.
projects/player/src/app/services/unit-state.service.ts
+
9
−
5
View file @
fd48eb85
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
Inject
,
Injectable
}
from
'
@angular/core
'
;
import
{
Observable
,
Subject
}
from
'
rxjs
'
;
import
{
DOCUMENT
}
from
'
@angular/common
'
;
import
{
StatusChangeElement
,
UnitStateElementCode
,
...
...
@@ -12,7 +13,7 @@ import {
import
{
TextElement
}
from
'
../../../../common/models/text-element
'
;
import
{
VideoElement
}
from
'
../../../../common/models/video-element
'
;
import
{
AudioElement
}
from
'
../../../../common/models/audio-element
'
;
import
{
Intersection
Service
}
from
'
./intersection
.service
'
;
import
{
Intersection
Detector
}
from
'
.
./classes
/intersection
-detector
'
;
@
Injectable
({
providedIn
:
'
root
'
...
...
@@ -20,9 +21,12 @@ import { IntersectionService } from './intersection.service';
export
class
UnitStateService
{
private
_presentedPageAdded
=
new
Subject
<
number
>
();
private
_unitStateElementCodeChanged
=
new
Subject
<
UnitStateElementCode
>
();
private
intersectionDetector
!
:
IntersectionDetector
;
unitStateElementCodes
!
:
UnitStateElementCode
[];
constructor
(
private
intersectionService
:
IntersectionService
)
{}
constructor
(@
Inject
(
DOCUMENT
)
private
document
:
Document
)
{
this
.
intersectionDetector
=
new
IntersectionDetector
(
document
);
}
private
getUnitStateElement
(
id
:
string
):
UnitStateElementCode
|
undefined
{
return
this
.
unitStateElementCodes
...
...
@@ -58,8 +62,8 @@ export class UnitStateService {
registerElement
(
elementModel
:
UIElement
,
element
:
Element
):
void
{
this
.
initUnitStateValue
(
elementModel
);
this
.
intersection
Service
.
observe
(
elementModel
.
id
,
element
);
this
.
intersection
Service
.
intersecting
this
.
intersection
Detector
.
observe
(
elementModel
.
id
,
element
);
this
.
intersection
Detector
.
intersecting
.
subscribe
((
id
:
string
)
=>
{
this
.
changeElementStatus
({
id
:
id
,
status
:
'
DISPLAYED
'
});
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment