Skip to content

Commit 1681006

Browse files
committed
fix: simplify constructor by initializing the properties in the class
1 parent a40b873 commit 1681006

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

src-commons-ui/float-pane/FloatPane.tsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,35 +49,31 @@ export class PinnedDatatip {
4949
_boundHandleMouseDown: Function
5050
_boundHandleCapturedClick: Function
5151
_mouseUpTimeout: NodeJS.Timeout | null = null
52-
_hostElement: HTMLElement
52+
_hostElement: HTMLElement = document.createElement("div")
5353
_marker?: DisplayMarker
5454
_rangeDecoration?: Decoration
5555
_mouseSubscription: Subscription | null = null
56-
_subscriptions: CompositeDisposable
56+
_subscriptions: CompositeDisposable = new CompositeDisposable()
5757
_datatip: Datatip
5858
_editor: TextEditor
5959
_dragOrigin: Position | null = null
60-
_isDragging: boolean
61-
_offset: Position
62-
_isHovering: boolean
63-
_checkedScrollable: boolean
64-
_isScrollable: boolean
60+
_isDragging: boolean = false
61+
_offset: Position = { x: 0, y: 0 }
62+
_isHovering: boolean = false
63+
_checkedScrollable: boolean = false
64+
_isScrollable: boolean = false
6565
_hideDataTips: () => void
6666
_position: PinnedDatatipPosition
6767
_showRangeHighlight: boolean
6868

6969
constructor(datatip: Datatip, editor: TextEditor, params: PinnedDatatipParams) {
70-
this._subscriptions = new CompositeDisposable()
7170
this._subscriptions.add(new Disposable(() => params.onDispose(this)))
7271
this._datatip = datatip
7372
this._editor = editor
74-
this._hostElement = document.createElement("div")
7573
this._hostElement.className = "datatip-element"
7674
this._boundDispose = this.dispose.bind(this)
7775
this._boundHandleMouseDown = this.handleMouseDown.bind(this)
7876
this._boundHandleCapturedClick = this.handleCapturedClick.bind(this)
79-
this._checkedScrollable = false
80-
this._isScrollable = false
8177

8278
const _wheelSubscription = fromEvent<WheelEvent>(this._hostElement, "wheel").subscribe((e) => {
8379
if (!this._checkedScrollable) {
@@ -100,9 +96,6 @@ export class PinnedDatatip {
10096
this._hostElement.removeEventListener("mouseleave", (e) => this.handleMouseLeave(e))
10197
})
10298
)
103-
this._offset = { x: 0, y: 0 }
104-
this._isDragging = false
105-
this._isHovering = false
10699
this._hideDataTips = params.hideDataTips
107100
this._position = params.position == null ? "end-of-line" : params.position
108101
this._showRangeHighlight = params.showRangeHighlight == null ? true : params.showRangeHighlight

0 commit comments

Comments
 (0)