Skip to content

Commit

Permalink
added panel change visibility public event (needed for react) issue 450
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-kurmanov committed Jun 19, 2017
1 parent 48fd2bf commit b1a1e80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,10 @@ export class PanelModelBase extends Base implements IConditionRunner, ILocalizab
if (value === this.visible) return;
this.visibleValue = value;
if(!this.isLoadingFromJson) this.onVisibleChanged();
this.panelVisibilityChanged(<Object>this, this.visible);
}
protected onVisibleChanged() {
}
public panelVisibilityChanged(panel:Object, visibility:boolean) {}
protected onVisibleChanged() {}
/**
* Returns true if object is visible or survey is in design mode right now.
*/
Expand Down
6 changes: 6 additions & 0 deletions src/react/reactpage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class SurveyPanel extends React.Component<any, any> {
this.survey = props.survey;
this.creator = props.creator;
this.css = props.css;
this.state = { modelChanged: 0 };
}
componentWillReceiveProps(nextProps: any) {
this.panel = nextProps.panel;
Expand All @@ -74,8 +75,13 @@ export class SurveyPanel extends React.Component<any, any> {
this.css = nextProps.css;
}
componentDidMount() {
var self = this;
var el = this.refs["root"];
if (el && this.survey) this.survey.afterRenderPage(el);
this.panel.panelVisibilityChanged = function(panel:Object, visibility:boolean) {
self.state.modelChanged = self.state.modelChanged + 1;
self.setState(self.state);
}
}
render(): JSX.Element {
if (this.panel == null || this.survey == null || this.creator == null) return null;
Expand Down

0 comments on commit b1a1e80

Please sign in to comment.