browser: fix TS eslint issues in ScrollSection
Signed-off-by: Dennis Francis <dennis.francis@collabora.com> Change-Id: I08d345bea972f8fac44975a915bf939cb6396d93
This commit is contained in:
parent
977f915106
commit
e6d09a9807
1 changed files with 51 additions and 39 deletions
|
@ -4,7 +4,9 @@
|
|||
declare var L: any;
|
||||
declare var app: any;
|
||||
|
||||
class ScrollSection extends CanvasSectionObject {
|
||||
namespace cool {
|
||||
|
||||
export class ScrollSection extends CanvasSectionObject {
|
||||
|
||||
map: any;
|
||||
autoScrollTimer: any;
|
||||
|
@ -37,7 +39,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
this.map.on('updatescrolloffset', this.onUpdateScrollOffset, this);
|
||||
}
|
||||
|
||||
public onInitialize () {
|
||||
public onInitialize (): void {
|
||||
this.sectionProperties.docLayer = this.map._docLayer;
|
||||
this.sectionProperties.mapPane = (<HTMLElement>(document.querySelectorAll('.leaflet-map-pane')[0]));
|
||||
this.sectionProperties.defaultCursorStyle = this.sectionProperties.mapPane.style.cursor;
|
||||
|
@ -99,14 +101,15 @@ class ScrollSection extends CanvasSectionObject {
|
|||
this.sectionProperties.quickScrollHorizontalTimer = null;
|
||||
}
|
||||
|
||||
public completePendingScroll() {
|
||||
public completePendingScroll(): void {
|
||||
if (this.pendingScrollEvent) {
|
||||
this.onScrollTo(this.pendingScrollEvent, true /* force */);
|
||||
this.pendingScrollEvent = null;
|
||||
}
|
||||
}
|
||||
|
||||
public onScrollTo (e: any, force: boolean = false) {
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
public onScrollTo (e: any, force: boolean = false): void {
|
||||
if (!force && !this.containerObject.drawingAllowed()) {
|
||||
// Only remember the last scroll-to position.
|
||||
this.pendingScrollEvent = e;
|
||||
|
@ -117,7 +120,8 @@ class ScrollSection extends CanvasSectionObject {
|
|||
this.map.scrollLeft(e.x, {});
|
||||
}
|
||||
|
||||
public onScrollBy (e: any) {
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
public onScrollBy (e: any): void {
|
||||
if (this.map._docLayer._docType !== 'spreadsheet') {
|
||||
this.scrollVerticalWithOffset(e.y);
|
||||
this.scrollHorizontalWithOffset(e.x);
|
||||
|
@ -146,7 +150,8 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
public onScrollVelocity (e: any) {
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
public onScrollVelocity (e: any): void {
|
||||
if (e.vx === 0 && e.vy === 0) {
|
||||
clearInterval(this.autoScrollTimer);
|
||||
this.autoScrollTimer = null;
|
||||
|
@ -175,7 +180,8 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
public onHandleAutoScroll (e :any) {
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
public onHandleAutoScroll (e :any): void {
|
||||
var vx = 0;
|
||||
var vy = 0;
|
||||
|
||||
|
@ -241,6 +247,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
public getVerticalScrollProperties (): any {
|
||||
this.calculateYMinMax();
|
||||
var result: any = {};
|
||||
|
@ -286,7 +293,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
return scrollSize;
|
||||
}
|
||||
|
||||
private calculateXMinMax () {
|
||||
private calculateXMinMax (): void {
|
||||
var diff: number = Math.round(app.view.size.pixels[0] - this.containerObject.getDocumentAnchorSection().size[0]);
|
||||
|
||||
if (diff >= 0) {
|
||||
|
@ -306,6 +313,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
public getHorizontalScrollProperties (): any {
|
||||
this.calculateXMinMax();
|
||||
var result: any = {};
|
||||
|
@ -326,14 +334,14 @@ class ScrollSection extends CanvasSectionObject {
|
|||
return result;
|
||||
}
|
||||
|
||||
public onUpdateScrollOffset () {
|
||||
public onUpdateScrollOffset (): void {
|
||||
if (this.map._docLayer._docType === 'spreadsheet') {
|
||||
this.map._docLayer.refreshViewData();
|
||||
this.map._docLayer.updateScollLimit();
|
||||
}
|
||||
}
|
||||
|
||||
private DrawVerticalScrollBarMobile () {
|
||||
private DrawVerticalScrollBarMobile (): void {
|
||||
var scrollProps: any = this.getVerticalScrollProperties();
|
||||
|
||||
if (this.sectionProperties.animatingVerticalScrollBar)
|
||||
|
@ -383,7 +391,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
this.context.globalAlpha = 1.0;
|
||||
}
|
||||
|
||||
private drawVerticalScrollBar () {
|
||||
private drawVerticalScrollBar (): void {
|
||||
var scrollProps: any = this.getVerticalScrollProperties();
|
||||
|
||||
var startX = this.isCalcRTL() ? this.sectionProperties.edgeOffset : this.size[0] - this.sectionProperties.scrollBarThickness - this.sectionProperties.edgeOffset;
|
||||
|
@ -426,7 +434,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
private drawHorizontalScrollBar () {
|
||||
private drawHorizontalScrollBar (): void {
|
||||
var scrollProps: any = this.getHorizontalScrollProperties();
|
||||
|
||||
var startY = this.size[1] - this.sectionProperties.scrollBarThickness - this.sectionProperties.edgeOffset;
|
||||
|
@ -473,7 +481,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
|
||||
}
|
||||
|
||||
private calculateCurrentAlpha (elapsedTime: number) {
|
||||
private calculateCurrentAlpha (elapsedTime: number): void {
|
||||
if (elapsedTime >= this.sectionProperties.fadeOutStartingTime) {
|
||||
this.sectionProperties.currentAlpha = Math.max((1 - ((elapsedTime - this.sectionProperties.fadeOutStartingTime) / this.sectionProperties.fadeOutDuration)) * this.sectionProperties.alphaWhenVisible, 0.1);
|
||||
}
|
||||
|
@ -482,7 +490,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
public onDraw (frameCount: number, elapsedTime: number) {
|
||||
public onDraw (frameCount: number, elapsedTime: number): void {
|
||||
if (this.isAnimating && frameCount >= 0)
|
||||
this.calculateCurrentAlpha(elapsedTime);
|
||||
|
||||
|
@ -498,12 +506,12 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
public onAnimationEnded (frameCount: number, elapsedTime: number) {
|
||||
public onAnimationEnded (frameCount: number, elapsedTime: number): void {
|
||||
this.sectionProperties.animatingVerticalScrollBar = false;
|
||||
this.sectionProperties.animatingHorizontalScrollBar = false;
|
||||
}
|
||||
|
||||
private fadeOutHorizontalScrollBar () {
|
||||
private fadeOutHorizontalScrollBar (): void {
|
||||
if (this.isAnimating) {
|
||||
this.resetAnimation();
|
||||
this.sectionProperties.animatingHorizontalScrollBar = true;
|
||||
|
@ -517,7 +525,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
private fadeOutVerticalScrollBar () {
|
||||
private fadeOutVerticalScrollBar (): void {
|
||||
if (this.isAnimating) {
|
||||
this.resetAnimation();
|
||||
this.sectionProperties.animatingVerticalScrollBar = true;
|
||||
|
@ -531,7 +539,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
private hideVerticalScrollBar () {
|
||||
private hideVerticalScrollBar (): void {
|
||||
if (this.sectionProperties.mouseIsOnVerticalScrollBar) {
|
||||
this.sectionProperties.mouseIsOnVerticalScrollBar = false;
|
||||
this.sectionProperties.mapPane.style.cursor = this.sectionProperties.defaultCursorStyle;
|
||||
|
@ -548,7 +556,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
private showVerticalScrollBar () {
|
||||
private showVerticalScrollBar (): void {
|
||||
if (this.isAnimating && this.sectionProperties.animatingVerticalScrollBar)
|
||||
this.containerObject.stopAnimating();
|
||||
|
||||
|
@ -561,7 +569,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
private hideHorizontalScrollBar () {
|
||||
private hideHorizontalScrollBar (): void {
|
||||
if (this.sectionProperties.mouseIsOnHorizontalScrollBar) {
|
||||
this.sectionProperties.mouseIsOnHorizontalScrollBar = false;
|
||||
this.sectionProperties.mapPane.style.cursor = this.sectionProperties.defaultCursorStyle;
|
||||
|
@ -578,7 +586,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
private showHorizontalScrollBar () {
|
||||
private showHorizontalScrollBar (): void {
|
||||
if (this.isAnimating && this.sectionProperties.animatingHorizontalScrollBar)
|
||||
this.containerObject.stopAnimating();
|
||||
|
||||
|
@ -591,7 +599,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
private isMouseOnScrollBar (point: Array<number>) {
|
||||
private isMouseOnScrollBar (point: Array<number>): void {
|
||||
const mirrorX = this.isCalcRTL();
|
||||
if (this.documentTopLeft[1] >= 0) {
|
||||
if ((!mirrorX && point[0] >= this.size[0] - this.sectionProperties.usableThickness)
|
||||
|
@ -624,12 +632,12 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
public onMouseLeave () {
|
||||
public onMouseLeave (): void {
|
||||
this.hideVerticalScrollBar();
|
||||
this.hideHorizontalScrollBar();
|
||||
}
|
||||
|
||||
public scrollVerticalWithOffset (offset: number) {
|
||||
public scrollVerticalWithOffset (offset: number): void {
|
||||
var go = true;
|
||||
if (offset > 0) {
|
||||
if (this.documentTopLeft[1] + offset > this.sectionProperties.yMax)
|
||||
|
@ -652,7 +660,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
public scrollHorizontalWithOffset (offset: number) {
|
||||
public scrollHorizontalWithOffset (offset: number): void {
|
||||
var go = true;
|
||||
if (offset > 0) {
|
||||
if (this.documentTopLeft[0] + offset > this.sectionProperties.xMax)
|
||||
|
@ -678,6 +686,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
return this.containerObject.doesSectionIncludePoint(docSection, point);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
private isMousePointerSycnWithVerticalScrollBar (scrollProps: any, position: Array<number>): boolean {
|
||||
// Keep this desktop-only for now.
|
||||
if (!(<any>window).mode.isDesktop())
|
||||
|
@ -708,6 +717,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
return pointerIsSyncWithScrollBar;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
private isMousePointerSycnWithHorizontalScrollBar (scrollProps: any, position: Array<number>): boolean {
|
||||
// Keep this desktop-only for now.
|
||||
if (!(<any>window).mode.isDesktop())
|
||||
|
@ -743,7 +753,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
return pointerIsSyncWithScrollBar;
|
||||
}
|
||||
|
||||
public onMouseMove (position: Array<number>, dragDistance: Array<number>, e: MouseEvent) {
|
||||
public onMouseMove (position: Array<number>, dragDistance: Array<number>, e: MouseEvent): void {
|
||||
this.clearQuickScrollTimeout();
|
||||
|
||||
if (this.sectionProperties.clickScrollVertical && this.containerObject.isDraggingSomething()) {
|
||||
|
@ -794,7 +804,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
When user presses the button while the mouse pointer is on the railway of the scroll bar but not on the scroll bar directly,
|
||||
we quickly scroll the document to that position.
|
||||
*/
|
||||
private quickScrollVertical (point: Array<number>, originalSign?: number) {
|
||||
private quickScrollVertical (point: Array<number>, originalSign?: number): void {
|
||||
// Desktop only for now.
|
||||
if (!(<any>window).mode.isDesktop())
|
||||
return;
|
||||
|
@ -826,7 +836,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
When user presses the button while the mouse pointer is on the railway of the scroll bar but not on the scroll bar directly,
|
||||
we quickly scroll the document to that position.
|
||||
*/
|
||||
private quickScrollHorizontal (point: Array<number>, originalSign?: number) {
|
||||
private quickScrollHorizontal (point: Array<number>, originalSign?: number): void {
|
||||
// Desktop only for now.
|
||||
if (!(<any>window).mode.isDesktop())
|
||||
return;
|
||||
|
@ -878,7 +888,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
public onMouseDown (point: Array<number>, e: MouseEvent) {
|
||||
public onMouseDown (point: Array<number>, e: MouseEvent): void {
|
||||
this.clearQuickScrollTimeout();
|
||||
this.onMouseMove(point, null, e);
|
||||
this.isMouseOnScrollBar(point);
|
||||
|
@ -926,7 +936,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
public onMouseUp (point: Array<number>, e: MouseEvent) {
|
||||
public onMouseUp (point: Array<number>, e: MouseEvent): void {
|
||||
this.map.scrollingIsHandled = false;
|
||||
this.clearQuickScrollTimeout();
|
||||
|
||||
|
@ -965,7 +975,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
this.onMouseMove(point, null, e);
|
||||
}
|
||||
|
||||
private performVerticalScroll (delta: number) {
|
||||
private performVerticalScroll (delta: number): void {
|
||||
this.scrollVerticalWithOffset(delta);
|
||||
if (!this.sectionProperties.drawVerticalScrollBar) {
|
||||
if (this.isAnimating) {
|
||||
|
@ -977,7 +987,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
private performHorizontalScroll (delta: number) {
|
||||
private performHorizontalScroll (delta: number): void {
|
||||
this.scrollHorizontalWithOffset(delta);
|
||||
if (!this.sectionProperties.drawHorizontalScrollBar) {
|
||||
if (this.isAnimating) {
|
||||
|
@ -989,7 +999,7 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
public onMouseWheel (point: Array<number>, delta: Array<number>, e: MouseEvent) {
|
||||
public onMouseWheel (point: Array<number>, delta: Array<number>, e: MouseEvent): void {
|
||||
if (e.ctrlKey)
|
||||
return;
|
||||
|
||||
|
@ -1005,6 +1015,8 @@ class ScrollSection extends CanvasSectionObject {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
L.getNewScrollSection = function () {
|
||||
return new ScrollSection();
|
||||
return new cool.ScrollSection();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue