Skip to content
This repository was archived by the owner on Feb 5, 2022. It is now read-only.

Commit 04c0157

Browse files
committed
fix(app-home): fix to scroll function when moving to another page
1 parent 0c214f6 commit 04c0157

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

src/pages/app-home/app-home.tsx

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,33 @@ export class AppHome {
2929

3030
/* tslint:disable-next-line */
3131
$(window).on('scroll resize', function() {
32-
const pos = $('#content-panel-inner').offset().top + $('#content-panel-inner').height() / 2;
33-
let done = false;
34-
$('.content-panel').each(function() {
35-
if (!done && pos <= Math.floor($(this).offset().top + $(this).height())) {
36-
const newDescr = $(this)
32+
if ($('#content-panel-inner') && $('#content-panel-inner').offset()) {
33+
const pos = $('#content-panel-inner').offset().top + $('#content-panel-inner').height() / 2;
34+
let done = false;
35+
$('.content-panel').each(function() {
36+
if (!done && pos <= Math.floor($(this).offset().top + $(this).height())) {
37+
const newDescr = $(this)
38+
.find('.description')
39+
.html();
40+
$('#content-panel-inner').html(newDescr);
41+
42+
done = true;
43+
}
44+
});
45+
46+
if (
47+
$('#content-panel-inner').offset().top ===
48+
$('.content-panel')
49+
.first()
50+
.offset().top
51+
) {
52+
const newDescr = $('.content-panel')
53+
.first()
3754
.find('.description')
3855
.html();
39-
$('#content-panel-inner').html(newDescr);
4056

41-
done = true;
57+
$('#content-panel-inner').html(newDescr);
4258
}
43-
});
44-
45-
if (
46-
$('#content-panel-inner').offset().top ===
47-
$('.content-panel')
48-
.first()
49-
.offset().top
50-
) {
51-
const newDescr = $('.content-panel')
52-
.first()
53-
.find('.description')
54-
.html();
55-
56-
$('#content-panel-inner').html(newDescr);
5759
}
5860
});
5961

0 commit comments

Comments
 (0)