当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Renderer.listenGlobal方法代码示例

本文整理汇总了TypeScript中@angular/core.Renderer.listenGlobal方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Renderer.listenGlobal方法的具体用法?TypeScript Renderer.listenGlobal怎么用?TypeScript Renderer.listenGlobal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/core.Renderer的用法示例。


在下文中一共展示了Renderer.listenGlobal方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: ngAfterViewInit

 ngAfterViewInit() {
     this.container = this.el.nativeElement.children[0];
     
     this.documentClickListener = this.renderer.listenGlobal('body', 'click', () => {
         this.hide();
     });
     
     this.documentRightClickListener = this.renderer.listenGlobal('body', 'contextmenu', (event) => {
         this.show(event);
         event.preventDefault();
     });
 }
开发者ID:AjaySharm,项目名称:primeng,代码行数:12,代码来源:contextmenu.ts

示例2: _listenGlobal

 private _listenGlobal(renderer: Renderer, eventTarget: string, eventName: string,
                       unlistenId: number) {
   var unregisterCallback = renderer.listenGlobal(
       eventTarget, eventName,
       (event: any /** TODO #9100 */) => this._eventDispatcher.dispatchRenderEvent(null, eventTarget, eventName, event));
   this._renderStore.store(unregisterCallback, unlistenId);
 }
开发者ID:aftab10662,项目名称:angular,代码行数:7,代码来源:renderer.ts

示例3: ngAfterViewInit

 ngAfterViewInit() {
   this._handleClick = this._renderer.listenGlobal('document', 'click', (event: Event) => {
     if (!this._hasChildMenu(event)) {
       this._closeMenu();
     }
   });
 }
开发者ID:Promact,项目名称:md2,代码行数:7,代码来源:menu-trigger.ts

示例4: enterPreDragState

	// I put the directive into a pre-drag state where we are checking to see if the 
	// depressed mouse is moved passed a certain threshold delta. It is only after the
	// delta is surpassed that we will start to emit drag events.
	private enterPreDragState() : void {

		// NOTE: In the pre-drag state, we are binding to the listeners on the global
		// target since the mouse may move outside the host element before the drag 
		// behavior is activated.

		var unbindMousemove = this.renderer.listenGlobal(
			"document",
			"mousemove",
			( event: MouseEvent ) : void => {

				var mouseDelta = Math.max(
					Math.abs( event.pageX - this.initialMouseLocation.x ),
					Math.abs( event.pageY - this.initialMouseLocation.y )
				);

				// If the mouse has moved past the threshold, teardown the state and
				// move to the drag state.
				if ( mouseDelta > 3 ) {

					unbindMousemove();
					unbindMouseup();
					this.enterDragState( event.pageX, event.pageY );

				}

			}
		);

		// If the user mouses-up in the pre-drag state, they never passed the drag 
		// threshold. As such, just teardown the state and move back to ready state.
		var unbindMouseup = this.renderer.listenGlobal(
			"document",
			"mouseup",
			( event: MouseEvent ) : void => {

				unbindMousemove();
				unbindMouseup();
				this.enterReadyState();

			}
		);

	}
开发者ID:CesarChaMal,项目名称:JavaScript-Demos,代码行数:47,代码来源:draggable.directive.ts

示例5: enterDragState

	// ---
	// PRIVATE METHODS.
	// ---


	// I put the directive into a drag state where new position events are being emitted
	// as the mouse is moved around. The events indicate where the host element should 
	// be moved if the calling context is implementing the drag.
	private enterDragState( newX: number, newY: number ) : void {

		// NOTE: In the drag state, we are binding to the listeners on the global
		// target since the mouse may move outside the host element if the position of 
		// the element is not updating fast enough; or, if the calling context is NOT
		// implementing a change in position.

		var unbindMousemove = this.renderer.listenGlobal(
			"document",
			"mousemove",
			( event: MouseEvent ) : void => {

				// Try to prevent text from being highlighted by the drag action.
				event.preventDefault();

				// Get the change in mouse location.
				var deltaX = ( event.pageX - this.initialMouseLocation.x );
				var deltaY = ( event.pageY - this.initialMouseLocation.y );

				// Use the mouse delta to calculate the element's position delta.
				this.positionChange.next({
					left: ( this.initialElementPosition.left + deltaX ),
					top: ( this.initialElementPosition.top + deltaY )
				});

			}
		);

		// If the user mouses-up in the pre-drag state, they never passed the drag 
		// threshold. As such, just teardown the state and move back to ready state.
		var unbindMouseup = this.renderer.listenGlobal(
			"document",
			"mouseup",
			( event: MouseEvent ) : void => {

				unbindMousemove();
				unbindMouseup();
				this.enterReadyState();

			}
		);

	}
开发者ID:CesarChaMal,项目名称:JavaScript-Demos,代码行数:51,代码来源:draggable.directive.ts

示例6: ngAfterViewInit

 ngAfterViewInit() {
     this.container = this.el.nativeElement.children[0];
     
     if(this.popup) {
         this.documentClickListener = this.renderer.listenGlobal('body', 'click', () => {
             if(!this.preventDocumentDefault) {
                 this.hide();
             }
             this.preventDocumentDefault = false;
         });
     }
 }
开发者ID:KorshakVladimir,项目名称:primeng,代码行数:12,代码来源:menu.ts

示例7: onSliderMouseDown

    public onSliderMouseDown(event: MouseEvent): void {
        console.log('onSliderMouseDown ' + this.element.nativeElement);

        this.trackWidthRange = this.getTrackWidthRange();

        this.jumpToPosition(event.clientX, this.trackWidthRange);

        this.freeMouseUpListener =
            this.renderer.listenGlobal(
                'document',
                'mouseup',
                (mouseEvent: MouseEvent) => {
                    this.onMouseUp(mouseEvent);
                });
        this.freeMouseMoveListener =
            this.renderer.listenGlobal(
                'document',
                'mousemove',
                (mouseEvent: MouseEvent) => {
                    this.onMouseMove(mouseEvent);
                });
    }
开发者ID:zhu04303661,项目名称:ionic-recorder,代码行数:22,代码来源:progress-slider.ts

示例8: constructor

  constructor(platform: Platform, renderer: Renderer, app: IonicApp) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
    });

    this.app = app;

    renderer.listenGlobal('document', 'wlInitFinished', () => {
      console.log('---> wlInitFinished event received');
      this.MFPInit();
    })
  }
开发者ID:thimico,项目名称:hybridMessenger-Angular2,代码行数:14,代码来源:app.ts

示例9: registerOutsideClick

export function registerOutsideClick(renderer: Renderer, options: ListenOptions) {
  if (!options.outsideClick) {
    return Function.prototype;
  }

  return renderer.listenGlobal('document', 'click', (event: any) => {
    if (options.target && options.target.contains(event.target)) {
      return;
    }
    if (options.targets && options.targets.some(target => target.contains(event.target))) {
      return;
    }
    options.hide();
  });
}
开发者ID:kekeh,项目名称:ngx-bootstrap,代码行数:15,代码来源:triggers.ts

示例10: constructor

 constructor(af:AngularFire, renderer: Renderer){
   this.URL = window.location.href;
   this.onOff = af.database.object('/'+this.URL.split('/game/')[1]+'/Globals/OnOff',{preserveSnapshot:true});
   this.onOff.subscribe(snapshot =>{
     this.environmentSnapshot = snapshot.val();
   });
   this.environment = af.database.object('/'+this.URL.split('/game/')[1]+'/Globals/Environment');
   this.players = af.database.object('/'+this.URL.split('/game/')[1]+'/Players',{preserveSnapshot:true});
   this.players.subscribe(snapshot =>{
     this.playersSnapshot = snapshot.val();
   });
   /* Gets keyup */
   this.getKey = renderer.listenGlobal('document', 'keyup', (event) => {
     var key = event.keyCode;
     this.toggleBtn(key);
   });
 }
开发者ID:JacobDeming,项目名称:HotfixEngine,代码行数:17,代码来源:environment.component.ts


注:本文中的@angular/core.Renderer.listenGlobal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。