Skip to content

Commit

Permalink
Fixed issue lsqlabs#145
Browse files Browse the repository at this point in the history
  • Loading branch information
eltongonc committed Jul 3, 2023
1 parent 0d75fc9 commit e115bf6
Showing 1 changed file with 19 additions and 29 deletions.
48 changes: 19 additions & 29 deletions projects/ngx-guided-tour/src/lib/guided-tour.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,43 +184,33 @@ export class GuidedTourComponent implements AfterViewInit, OnDestroy {
this.updateStepLocation();
// Allow things to render to scroll to the correct location
setTimeout(() => {
if (!this.isOrbShowing && !this.isTourOnScreen()) {
if (this.selectedElementRect && this.isBottom()) {
if (!this.isOrbShowing && !this.isTourOnScreen() && this.selectedElementRect) {
let topPos;

if (this.isBottom()) {
// Scroll so the element is on the top of the screen.
const topPos = ((this.windowRef.nativeWindow.scrollY + this.selectedElementRect.top) - this.topOfPageAdjustment)
topPos = ((this.windowRef.nativeWindow.scrollY + this.selectedElementRect.top) - this.topOfPageAdjustment)
- (this.currentTourStep.scrollAdjustment ? this.currentTourStep.scrollAdjustment : 0)
+ this.getStepScreenAdjustment();
try {
this.windowRef.nativeWindow.scrollTo({
left: null,
top: topPos,
behavior: 'smooth'
});
} catch (err) {
if (err instanceof TypeError) {
this.windowRef.nativeWindow.scroll(0, topPos);
} else {
throw err;
}
}
} else {
// Scroll so the element is on the bottom of the screen.
const topPos = (this.windowRef.nativeWindow.scrollY + this.selectedElementRect.top + this.selectedElementRect.height)
topPos = (this.windowRef.nativeWindow.scrollY + this.selectedElementRect.top + this.selectedElementRect.height)
- this.windowRef.nativeWindow.innerHeight
+ (this.currentTourStep.scrollAdjustment ? this.currentTourStep.scrollAdjustment : 0)
- this.getStepScreenAdjustment();
try {
this.windowRef.nativeWindow.scrollTo({
left: null,
top: topPos,
behavior: 'smooth'
});
} catch (err) {
if (err instanceof TypeError) {
this.windowRef.nativeWindow.scroll(0, topPos);
} else {
throw err;
}
}

try {
this.windowRef.nativeWindow.scrollTo({
left: null,
top: topPos,
behavior: 'smooth'
});
} catch (err) {
if (err instanceof TypeError) {
this.windowRef.nativeWindow.scroll(0, topPos);
} else {
throw err;
}
}
}
Expand Down

0 comments on commit e115bf6

Please sign in to comment.