Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
X-tee
X-Road-catalogue
Commits
dd2608b6
Commit
dd2608b6
authored
Mar 06, 2019
by
Vitali Stupin
Browse files
Restore scroll position for subsystem view
parent
9542926a
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/app/subsystem-list/subsystem-list.component.ts
View file @
dd2608b6
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
Component
,
OnInit
,
OnDestroy
}
from
'
@angular/core
'
;
import
{
Subsystem
}
from
'
../subsystem
'
;
import
{
MethodsService
}
from
'
../methods.service
'
;
import
{
LanguagesService
}
from
'
../languages.service
'
;
import
{
ActivatedRoute
,
Router
,
Scroll
}
from
'
@angular/router
'
;
import
{
Subscription
}
from
'
rxjs
'
;
import
{
ViewportScroller
}
from
'
@angular/common
'
;
...
...
@@ -12,7 +11,7 @@ import { filter } from 'rxjs/operators';
templateUrl
:
'
./subsystem-list.component.html
'
,
styleUrls
:
[
'
./subsystem-list.component.css
'
]
})
export
class
SubsystemListComponent
implements
OnInit
{
export
class
SubsystemListComponent
implements
OnInit
,
OnDestroy
{
subsystems
:
Subsystem
[]
message
:
string
=
''
scrollPosition
:
[
number
,
number
]
...
...
@@ -23,7 +22,6 @@ export class SubsystemListComponent implements OnInit {
constructor
(
private
methodsService
:
MethodsService
,
private
languagesService
:
LanguagesService
,
private
route
:
ActivatedRoute
,
private
router
:
Router
,
private
viewportScroller
:
ViewportScroller
...
...
src/app/subsystem/subsystem.component.ts
View file @
dd2608b6
import
{
Component
,
OnInit
,
OnDestroy
}
from
'
@angular/core
'
;
import
{
MethodsService
}
from
'
../methods.service
'
;
import
{
Subsystem
}
from
'
../subsystem
'
;
import
{
ActivatedRoute
,
Router
}
from
'
@angular/router
'
;
import
{
ActivatedRoute
,
Router
,
Scroll
}
from
'
@angular/router
'
;
import
{
Subscription
}
from
'
rxjs
'
;
import
{
ViewportScroller
}
from
'
@angular/common
'
;
import
{
filter
}
from
'
rxjs/operators
'
;
@
Component
({
selector
:
'
app-subsystem
'
,
...
...
@@ -13,6 +15,8 @@ export class SubsystemComponent implements OnInit, OnDestroy {
subsystem
:
Subsystem
subsystemId
:
string
message
:
string
=
''
scrollPosition
:
[
number
,
number
]
routerScrollSubscription
:
Subscription
routeSubscription
:
Subscription
updatedSubscription
:
Subscription
warningsSubscription
:
Subscription
...
...
@@ -20,8 +24,20 @@ export class SubsystemComponent implements OnInit, OnDestroy {
constructor
(
private
methodsService
:
MethodsService
,
private
route
:
ActivatedRoute
,
private
router
:
Router
)
{
}
private
router
:
Router
,
private
viewportScroller
:
ViewportScroller
)
{
// Geting previous scroll position
this
.
routerScrollSubscription
=
this
.
router
.
events
.
pipe
(
filter
(
e
=>
e
instanceof
Scroll
)
).
subscribe
(
e
=>
{
if
((
e
as
Scroll
).
position
)
{
this
.
scrollPosition
=
(
e
as
Scroll
).
position
;
}
else
{
this
.
scrollPosition
=
[
0
,
0
];
}
});
}
private
checkSubsystem
()
{
// Do not overwrite previous warnings
...
...
@@ -67,7 +83,13 @@ export class SubsystemComponent implements OnInit, OnDestroy {
}
}
ngAfterViewInit
()
{
// Restoring scroll position
this
.
viewportScroller
.
scrollToPosition
(
this
.
scrollPosition
);
}
ngOnDestroy
()
{
this
.
routerScrollSubscription
.
unsubscribe
()
this
.
routeSubscription
.
unsubscribe
()
this
.
updatedSubscription
.
unsubscribe
()
this
.
warningsSubscription
.
unsubscribe
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment