33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import { $ , append , EventHelper , EventLike , getWindow , isHTMLElement } from '../../dom.js' ;
6+ import { $ , addDisposableListener , append , EventHelper , EventLike , getWindow , isHTMLElement } from '../../dom.js' ;
77import { createStyleSheet } from '../../domStylesheets.js' ;
88import { DomEmitter } from '../../event.js' ;
99import { EventType , Gesture } from '../../touch.js' ;
@@ -345,10 +345,8 @@ export class Sash extends Disposable {
345345 if ( state !== SashState . Disabled ) {
346346 this . _orthogonalStartDragHandle = append ( this . el , $ ( '.orthogonal-drag-handle.start' ) ) ;
347347 this . orthogonalStartDragHandleDisposables . add ( toDisposable ( ( ) => this . _orthogonalStartDragHandle ! . remove ( ) ) ) ;
348- this . orthogonalStartDragHandleDisposables . add ( new DomEmitter ( this . _orthogonalStartDragHandle , 'mouseenter' ) ) . event
349- ( ( ) => Sash . onMouseEnter ( sash ) , undefined , this . orthogonalStartDragHandleDisposables ) ;
350- this . orthogonalStartDragHandleDisposables . add ( new DomEmitter ( this . _orthogonalStartDragHandle , 'mouseleave' ) ) . event
351- ( ( ) => Sash . onMouseLeave ( sash ) , undefined , this . orthogonalStartDragHandleDisposables ) ;
348+ this . orthogonalStartDragHandleDisposables . add ( addDisposableListener ( this . _orthogonalStartDragHandle , 'mouseenter' , ( ) => Sash . onMouseEnter ( sash ) ) ) ;
349+ this . orthogonalStartDragHandleDisposables . add ( addDisposableListener ( this . _orthogonalStartDragHandle , 'mouseleave' , ( ) => Sash . onMouseLeave ( sash ) ) ) ;
352350 }
353351 } ;
354352
@@ -383,10 +381,8 @@ export class Sash extends Disposable {
383381 if ( state !== SashState . Disabled ) {
384382 this . _orthogonalEndDragHandle = append ( this . el , $ ( '.orthogonal-drag-handle.end' ) ) ;
385383 this . orthogonalEndDragHandleDisposables . add ( toDisposable ( ( ) => this . _orthogonalEndDragHandle ! . remove ( ) ) ) ;
386- this . orthogonalEndDragHandleDisposables . add ( new DomEmitter ( this . _orthogonalEndDragHandle , 'mouseenter' ) ) . event
387- ( ( ) => Sash . onMouseEnter ( sash ) , undefined , this . orthogonalEndDragHandleDisposables ) ;
388- this . orthogonalEndDragHandleDisposables . add ( new DomEmitter ( this . _orthogonalEndDragHandle , 'mouseleave' ) ) . event
389- ( ( ) => Sash . onMouseLeave ( sash ) , undefined , this . orthogonalEndDragHandleDisposables ) ;
384+ this . orthogonalEndDragHandleDisposables . add ( addDisposableListener ( this . _orthogonalEndDragHandle , 'mouseenter' , ( ) => Sash . onMouseEnter ( sash ) ) ) ;
385+ this . orthogonalEndDragHandleDisposables . add ( addDisposableListener ( this . _orthogonalEndDragHandle , 'mouseleave' , ( ) => Sash . onMouseLeave ( sash ) ) ) ;
390386 }
391387 } ;
392388
@@ -427,23 +423,17 @@ export class Sash extends Disposable {
427423 this . el . classList . add ( 'mac' ) ;
428424 }
429425
430- const onMouseDown = this . _register ( new DomEmitter ( this . el , 'mousedown' ) ) . event ;
431- this . _register ( onMouseDown ( e => this . onPointerStart ( e , new MouseEventFactory ( container ) ) , this ) ) ;
432- const onMouseDoubleClick = this . _register ( new DomEmitter ( this . el , 'dblclick' ) ) . event ;
433- this . _register ( onMouseDoubleClick ( this . onPointerDoublePress , this ) ) ;
434- const onMouseEnter = this . _register ( new DomEmitter ( this . el , 'mouseenter' ) ) . event ;
435- this . _register ( onMouseEnter ( ( ) => Sash . onMouseEnter ( this ) ) ) ;
436- const onMouseLeave = this . _register ( new DomEmitter ( this . el , 'mouseleave' ) ) . event ;
437- this . _register ( onMouseLeave ( ( ) => Sash . onMouseLeave ( this ) ) ) ;
426+ this . _register ( addDisposableListener ( this . el , 'mousedown' , e => this . onPointerStart ( e , new MouseEventFactory ( container ) ) ) ) ;
427+ this . _register ( addDisposableListener ( this . el , 'dblclick' , e => this . onPointerDoublePress ( e ) ) ) ;
428+ this . _register ( addDisposableListener ( this . el , 'mouseenter' , ( ) => Sash . onMouseEnter ( this ) ) ) ;
429+ this . _register ( addDisposableListener ( this . el , 'mouseleave' , ( ) => Sash . onMouseLeave ( this ) ) ) ;
438430
439431 this . _register ( Gesture . addTarget ( this . el ) ) ;
440432
441- const onTouchStart = this . _register ( new DomEmitter ( this . el , EventType . Start ) ) . event ;
442- this . _register ( onTouchStart ( e => this . onPointerStart ( e , new GestureEventFactory ( this . el ) ) , this ) ) ;
443- const onTap = this . _register ( new DomEmitter ( this . el , EventType . Tap ) ) . event ;
433+ this . _register ( addDisposableListener ( this . el , EventType . Start , e => this . onPointerStart ( e , new GestureEventFactory ( this . el ) ) ) ) ;
444434
445435 let doubleTapTimeout : Timeout | undefined = undefined ;
446- this . _register ( onTap ( event => {
436+ this . _register ( addDisposableListener ( this . el , EventType . Tap , event => {
447437 if ( doubleTapTimeout ) {
448438 clearTimeout ( doubleTapTimeout ) ;
449439 doubleTapTimeout = undefined ;
@@ -453,7 +443,7 @@ export class Sash extends Disposable {
453443
454444 clearTimeout ( doubleTapTimeout ) ;
455445 doubleTapTimeout = setTimeout ( ( ) => doubleTapTimeout = undefined , 250 ) ;
456- } , this ) ) ;
446+ } ) ) ;
457447
458448 if ( typeof options . size === 'number' ) {
459449 this . size = options . size ;
0 commit comments