# 如何在 widget 中检测可见性变化？

**URL:** https://meta.discourse.org/t/how-to-detect-visibility-change-in-widget/115951
**Category:** Support
**Created:** [2019年四月25日 11:24 UTC](https://meta.discourse.org/t/how-to-detect-visibility-change-in-widget/115951 "2019-04-25T11:24:55Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [2019年四月25日 17:45 UTC](https://meta.discourse.org/t/how-to-detect-visibility-change-in-widget/115951/2 "2019-04-25T17:45:43Z")

</div>

Would this do the trick?

```js
const showExtraInfo = helper.attrs.topic;
  if(!showExtraInfo) {
    
  }

```

`showExtraInfo` is the scrolled state with the title in the header

Full example using decorateWidget here

> [@Adding header links post vdom upgrade](https://meta.discourse.org/t/adding-header-links-post-vdom-upgrade/43284/3):
>
> Ah, well this worked: \<script type="text/discourse-plugin" version="0.2"\> api.decorateWidget('header:after', helper =\> { const showExtraInfo = helper.attrs.topic; if(!showExtraInfo) { return helper.h('div#header-links', [ helper.h('a#recruiter', { href:'https://sih.onemadogre.com/t/joining-sih/494', text:'Join Us!' }), helper.h('a#about', { href:'https://sih.onema…

---

_[View the full topic](https://meta.discourse.org/t/how-to-detect-visibility-change-in-widget/115951)._
