本文整理汇总了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();
});
}
示例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);
}
示例3: ngAfterViewInit
ngAfterViewInit() {
this._handleClick = this._renderer.listenGlobal('document', 'click', (event: Event) => {
if (!this._hasChildMenu(event)) {
this._closeMenu();
}
});
}
示例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();
}
);
}
示例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();
}
);
}
示例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;
});
}
}
示例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);
});
}
示例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();
})
}
示例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();
});
}
示例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);
});
}