Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
X-tee
X-Road-catalogue
Commits
dd2608b6
Commit
dd2608b6
authored
Mar 06, 2019
by
Vitali Stupin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restore scroll position for subsystem view
parent
9542926a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
7 deletions
+27
-7
src/app/subsystem-list/subsystem-list.component.ts
src/app/subsystem-list/subsystem-list.component.ts
+2
-4
src/app/subsystem/subsystem.component.ts
src/app/subsystem/subsystem.component.ts
+25
-3
No files found.
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
Markdown
is supported
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