#How to track down why component method is called for every scroll position change?

8 messages · Page 1 of 1 (latest)

tall maple
#

I put a console.log statement in one of my components to observe some data behavior, but I happen to notice that the method is being called for every change in the document's scroll position. Is this change detection? I'm not using any 3rd party component libs. Any advice on how to begin tracking down why this is happening?

bold bay
#

g!codeblock @tall maple Show your code

dusty ventureBOT
#

@tall maple, you can use the following snippet to have your code formatted and colored by Discord. Replace ts with the language you need (i.e. html, js, css, etc)
```ts
// your code goes here
```

tall maple
#
<div *ngIf="show()">
  <h3>{{ title }}</h3>
  <div *ngFor="let item of items" [attr.data-ts-view]="item.views" class="container flex-v">
    <div class="flex">
      <ts-themed-svg *ngIf="item.data.type.visual" [id]="item.data.type.visual"
                     class="ts-icon-small ts-icon-margin-right">
      </ts-themed-svg>
      <ts-nullable-link [displayText]="item.data.type.name" [url]="item.data.type.uri"></ts-nullable-link>
    </div>
    <ts-formatted-content [content]="item.data.content"></ts-formatted-content>
  </div>
</div>
#
import { Component, Input } from "@angular/core";
import { ViewData } from "../../dto/view-data";
import { TypeContentNode } from "../../dto/type-content-node";

@Component({
  selector: "ts-type-content-table",
  templateUrl: "./type-content-table.component.html",
  styleUrls: ["./type-content-table.component.css"]
})
export class TypeContentTableComponent {
  @Input() items: ViewData<TypeContentNode>[]=[];
  @Input() title = "Items";

  show(){
    console.log("show called");
    return this.items.length > 0;
  }
}
tall maple
#

Excellent! Thank you!