浏览代码

PanelModel: expose isInView property to PanelModel (#16877)

Ryan McKinley 6 年之前
父节点
当前提交
bb64a0673d

+ 2 - 1
public/app/features/dashboard/dashgrid/DashboardGrid.tsx

@@ -233,6 +233,7 @@ export class DashboardGrid extends PureComponent<Props> {
     for (const panel of this.props.dashboard.panels) {
       const panelClasses = classNames({ 'react-grid-item--fullscreen': panel.fullscreen });
       const id = panel.id.toString();
+      panel.isInView = this.isInView(panel);
       panelElements.push(
         <div
           key={id}
@@ -247,7 +248,7 @@ export class DashboardGrid extends PureComponent<Props> {
             dashboard={this.props.dashboard}
             isEditing={panel.isEditing}
             isFullscreen={panel.fullscreen}
-            isInView={this.isInView(panel)}
+            isInView={panel.isInView}
           />
         </div>
       );

+ 2 - 0
public/app/features/dashboard/state/PanelModel.ts

@@ -23,6 +23,7 @@ const notPersistedProperties: { [str: string]: boolean } = {
   events: true,
   fullscreen: true,
   isEditing: true,
+  isInView: true,
   hasRefreshed: true,
   cachedPluginOptions: true,
   plugin: true,
@@ -111,6 +112,7 @@ export class PanelModel {
   // non persisted
   fullscreen: boolean;
   isEditing: boolean;
+  isInView: boolean;
   hasRefreshed: boolean;
   events: Emitter;
   cacheTimeout?: any;