• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript core.ElementRef类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: myLayout

    	myLayout(el:ElementRef) {
		
		let container = el.getClientRects()[0];
		
		let c_width = container.width,   //container-height
		    c_height = container.height,
			
			h_width = 150,   //hex size
			h_height = 86,
			w_dist = 6,     
			h_dist = 46;
			
	
	}
开发者ID:kevinchen278,项目名称:innlab,代码行数:14,代码来源:demod.component.ts


示例2: myLayout

 	myLayout(el:ElementRef) {
		
		let container = el.getClientRects()[0];
		
		let c_width = container.width,   //container-height
		    c_height = container.height,
			
			h_width = 150,   //hex size
			h_height = 86,
			w_dist = 6,     
			h_dist = 46;
			
		if (c_width>639) {
			let pad_left = c_width/2 - (h_width + w_dist) * 4/2,
			    level_top1 = 55,
				level_height = h_height + h_dist + w_dist/2,
				row_width = h_width + w_dist;
			
			//layer 1
			
			el.children[0].style.left = pad_left + 1.5*row_width;
			el.children[0].style.top = level_top1;
			
            //layer 2
			el.children[1].style.left = pad_left + row_width;
			el.children[1].style.top = level_top1 + level_height;

			el.children[2].style.left = pad_left + 2*row_width;
			el.children[2].style.top = level_top1 + level_height;

            //layer 3
			el.children[3].style.left = pad_left + 0.5*row_width;
			el.children[3].style.top = level_top1 + 2*level_height;

			el.children[9].style.left = pad_left + 1.5*row_width;
			el.children[9].style.top = level_top1 + 2*level_height + 13 ;

			el.children[4].style.left = pad_left + 2.5*row_width ;
			el.children[4].style.top = level_top1 + 2*level_height ;


            //layer 4
			el.children[6].style.left = pad_left + 0*row_width;
			el.children[6].style.top = level_top1 + 3*level_height ;
			
			el.children[7].style.left = pad_left + 1*row_width ;
			el.children[7].style.top = level_top1 + 3 * level_height;

			el.children[8].style.left = pad_left + 2 * row_width ;
			el.children[8].style.top = level_top1 + 3 * level_height ;
			
			el.children[5].style.left = pad_left + 3*row_width;
			el.children[5].style.top = level_top1 + 3 * level_height ;			


		} else if (c_width > 480 ) {
			let pad_left = c_width/2 - (h_width + w_dist) * 3/2,
			    level_top1 = 55,
				level_height = h_height + h_dist + w_dist/2,
				row_width = h_width + w_dist;
			
			//layer 1
			
			el.children[0].style.left = pad_left ;
			el.children[0].style.top = level_top1;
			
			el.children[1].style.left = pad_left + row_width;
			el.children[1].style.top = level_top1;

			el.children[2].style.left = pad_left + 2*row_width;
			el.children[2].style.top = level_top1;


			//layer 2
			el.children[3].style.left = pad_left + 0.5*row_width;
			el.children[3].style.top = level_top1 + level_height ;

			el.children[4].style.left = pad_left + 1.5*row_width ;
			el.children[4].style.top = level_top1 + level_height ;
			
			//lay-3
			el.children[9].style.left = pad_left + 1*row_width;
			el.children[9].style.top = level_top1 + 2 * level_height + 13;			
			
			
			//lay-4

			el.children[5].style.left = pad_left + 0.5*row_width;
			el.children[5].style.top = level_top1 + 3*level_height ;

			el.children[6].style.left = pad_left + 1.5*row_width;
			el.children[6].style.top = level_top1 + 3*level_height ;
			
			//layer 5

			el.children[7].style.left = pad_left  ;
			el.children[7].style.top = level_top1 + 4 * level_height;

			el.children[8].style.left = pad_left + 1 * row_width ;
			el.children[8].style.top = level_top1 + 4 * level_height ;
//.........这里部分代码省略.........
开发者ID:kevinchen278,项目名称:innlab,代码行数:101,代码来源:demo.component.ts


示例3: ngAfterViewInit

    ngAfterViewInit() {
        const down = Observable.fromEvent(this.down.nativeElement, 'click')
        const up = Observable.fromEvent(this.up.nativeElement, 'click')

        this.counter = down
            .mapTo(-1)
            .merge(up.mapTo(1))
            .startWith(0)
            .scan<number>((prev, cur) => prev+cur, 0)

        down
            .buffer(down.debounceTime(250))
            .map(clicks => clicks.length)
            .filter(length => length == 2)
            .subscribe(
                (val) => console.log('doubleclick', val),
                (err) => console.error(err),
                () => console.log('complete')
            )

        // down
        //     .bufferTime(250)
        //     // .filter((clicks:any[]) => clicks.length > 1)
        //     .subscribe((val) => {
        //         console.log('buff', val);
        //     })
    }
开发者ID:pawelkocot,项目名称:frp,代码行数:27,代码来源:app.component.ts


示例4: ngAfterContentInit

 ngAfterContentInit() {
   let el = this.el.nativeElement;
   let title = el.querySelector('panel-title');
   let content = el.querySelector('panel-content');
   title.innerHTML = this.md.toHTML(title.innerHTML);
   content.innerHTML = this.md.toHTML(content.innerHTML);
 }
开发者ID:HalasNet,项目名称:switching-to-angular2,代码行数:7,代码来源:app.ts


示例5: showActive

  /**
   * Show active indication.
   */
  public showActive(): void {
    const line = this.line.nativeElement as StackLayout;
    line.opacity = 1;

    if (line.ios) {
      line.animate({
        duration: 1000,
        scale: { x: 1.0, y: 1.0 },
        curve: AnimationCurve.easeInOut,
      });
    } else {
      line.scaleX = 1;
    }
  }
开发者ID:racketometer,项目名称:frontend-application,代码行数:17,代码来源:tab.component.ts


示例6: ngOnInit

 ngOnInit() {
   let user = this.session.get().user;
   let color = 'black';
   if (user && user.theme_color && user.theme_color.accent) {
     color = user.theme_color.accent;
   }
   let style = document.createElement('style');
   style.type = 'text/css';
   style.innerHTML = `
     a:hover, .activeLink { color: ${color} !important; }
     a:hover .badge, .activeLink .badge { background: ${color} !important; }
   `;
   let el = this.el.nativeElement;
   el.insertBefore(style, el.firstChild);
 }
开发者ID:StudioProcess,项目名称:imagetool,代码行数:15,代码来源:navigation.component.ts


示例7: recalculateDimensionsAndSetMode

    recalculateDimensionsAndSetMode() {
        var el = this.el.nativeElement.getElementsByClassName('view')[0];
        var rect = el.getBoundingClientRect();
        this.width = rect.width;
        this.height = rect.height;

        var adjustedMode = window.getComputedStyle(document.querySelector('body'), ':before').getPropertyValue('content').replace(/\"/g, '');

        if (this.mode != adjustedMode) {
            this.mode = adjustedMode;
            var time = new Date();
            this.lastModeChange = time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
            this.modeChanged();
        }
    }
开发者ID:HydAu,项目名称:ng2VscodeTemplate,代码行数:15,代码来源:template.component.ts


示例8: gameLoop

 animate(playerClass,playerAction){
   /* Set up canvas variables */
   var canvas = this.canvas.nativeElement;
   var character,characterImage;
   function gameLoop(){
     window.requestAnimationFrame(gameLoop);
     character.update();
     character.render();
   }
   /* Animate based on player and action */
   switch(playerClass){
     // elementalist : piccolo
     case ("Elementalist"):
       switch(playerAction){
         case("strike"):
           // Get canvas
           canvas.width = 150;
           canvas.height = 162;
           // Create sprite sheet
           characterImage = new Image();
           // Create sprite
           character = this.sprite({
             context: canvas.getContext("2d"),
             width: 450,
             height: 162,
             image: characterImage,
             numberOfFrames: 3,
             ticksPerFrame: 4
           });
           // Load sprite sheet
           characterImage.addEventListener("load", gameLoop);
           characterImage.src = "images/sprites/player-2/piccolo/piccolo-punch.png";
           break;
         case("special"):
           // Get canvas
           canvas.width = 190;
           canvas.height = 162;
           // Create sprite sheet
           characterImage = new Image();
           // Create sprite
           character = this.sprite({
             context: canvas.getContext("2d"),
             width: 380,
             height: 162,
             image: characterImage,
             numberOfFrames: 2,
             ticksPerFrame: 20
           });
           // Load sprite sheet
           characterImage.addEventListener("load", gameLoop);
           characterImage.src = "images/sprites/player-2/piccolo/piccolo-magic.png";
           break;
         case("defend"):
           // Get canvas
           canvas.width = 120;
           canvas.height = 162;
           // Create sprite sheet
           characterImage = new Image();
           // Create sprite
           character = this.sprite({
             context: canvas.getContext("2d"),
             width: 240,
             height: 162,
             image: characterImage,
             numberOfFrames: 2,
             ticksPerFrame: 20
           });
           // Load sprite sheet
           characterImage.addEventListener("load", gameLoop);
           characterImage.src = "images/sprites/player-2/piccolo/piccolo-defend.png";
           break;
         default:
           this.animateStance(playerClass);
       }
       break;
     // highwayman : trunks
     case ("Highwayman"):
       switch(playerAction){
         case("strike"):
           // Get canvas
           canvas.width = 185;
           canvas.height = 162;
           // Create sprite sheet
           characterImage = new Image();
           // Create sprite
           character = this.sprite({
             context: canvas.getContext("2d"),
             width: 556,
             height: 162,
             image: characterImage,
             numberOfFrames: 3,
             ticksPerFrame: 8
           });
           // Load sprite sheet
           characterImage.addEventListener("load", gameLoop);
           characterImage.src = "images/sprites/player-2/trunks/trunks-punch.png";
           break;
         case("special"):
           // Get canvas
           canvas.width = 190;
//.........这里部分代码省略.........
开发者ID:JacobDeming,项目名称:HotfixEngine,代码行数:101,代码来源:player2sprite.component.ts


示例9: gameLoop

 animateDefeat(playerClass){
   /* Set up canvas variables */
   var canvas = this.canvas.nativeElement;
   var character,characterImage;
   function gameLoop(){
     window.requestAnimationFrame(gameLoop);
     character.update();
     character.render();
   }
   switch(playerClass){
     case("Elementalist"):
       // Get canvas
       canvas.width = 162;
       canvas.height = 162;
       // Create sprite sheet
       characterImage = new Image();
       // Create sprite
       character = this.sprite({
         context: canvas.getContext("2d"),
         width: canvas.width,
         height: canvas.height,
         image: characterImage,
         numberOfFrames: 1,
         ticksPerFrame: 10
       });
       // Load sprite sheet
       characterImage.addEventListener("load", gameLoop);
       characterImage.src = "images/sprites/player-1/piccolo/piccolo-defeat.png";
       break;
     case("Highwayman"):
       // Get canvas
       canvas.width = 177;
       canvas.height = 162;
       // Create sprite sheet
       characterImage = new Image();
       // Create sprite
       character = this.sprite({
         context: canvas.getContext("2d"),
         width: canvas.width,
         height: canvas.height,
         image: characterImage,
         numberOfFrames: 1,
         ticksPerFrame: 10
       });
       // Load sprite sheet
       characterImage.addEventListener("load", gameLoop);
       characterImage.src = "images/sprites/player-1/trunks/trunks-defeat.png";
       break;
     case("Paragon"):
       // Get canvas
       canvas.width = 162;
       canvas.height = 162;
       // Create sprite sheet
       characterImage = new Image();
       // Create sprite
       character = this.sprite({
         context: canvas.getContext("2d"),
         width: canvas.width,
         height: canvas.height,
         image: characterImage,
         numberOfFrames: 1,
         ticksPerFrame: 10
       });
       // Load sprite sheet
       characterImage.addEventListener("load", gameLoop);
       characterImage.src = "images/sprites/player-1/gohan/gohan-defeat.png";
       break;
   }
 }
开发者ID:JacobDeming,项目名称:HotfixEngine,代码行数:69,代码来源:player1sprite.component.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript core.EmbeddedViewRef类代码示例发布时间:2022-05-28
下一篇:
TypeScript core.DynamicComponentLoader类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap