Skip to content

Commit

Permalink
add scroll event handler for form
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaLarina committed Sep 28, 2023
1 parent cac1724 commit c0cd72e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2101,10 +2101,11 @@ export class SurveyModel extends SurveyElementCore
this.renderBackgroundImage = wrapUrlForBackgroundImage(path);
}
@property() backgroundImageFit: ImageFit;
@property({ onSet: (newValue, target: SurveyModel) => {
target.backgroundImageFixed = newValue === "fixed";
target.updateCss(); } }) backgroundImageAttachment: ImageAttachment;
@property() backgroundImageFixed: boolean;
@property({
onSet: (newValue, target: SurveyModel) => {
target.updateCss();
}
}) backgroundImageAttachment: ImageAttachment;
/**
* A value from 0 to 1 that specifies how transparent the [background image](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#backgroundImage) should be: 0 makes the image completely transparent, and 1 makes it opaque.
*/
Expand All @@ -2127,7 +2128,7 @@ export class SurveyModel extends SurveyElementCore
public updateWrapperFormCss(): void {
this.wrapperFormCss = new CssClassBuilder()
.append(this.css.rootWrapper)
.append(this.css.rootWrapperFixed, this.backgroundImageFixed)
.append(this.css.rootWrapperFixed, this.backgroundImageAttachment === "fixed")
.toString();
}
/**
Expand Down Expand Up @@ -7386,13 +7387,19 @@ export class SurveyModel extends SurveyElementCore
public addScrollEventListener(): void {
this.scrollHandler = () => { this.onScroll(); };
this.rootElement.addEventListener("scroll", this.scrollHandler);
if(!!this.rootElement.getElementsByTagName("form")[0]) {
this.rootElement.getElementsByTagName("form")[0].addEventListener("scroll", this.scrollHandler);
}
if(!!this.css.rootWrapper) {
this.rootElement.getElementsByClassName(this.css.rootWrapper)[0]?.addEventListener("scroll", this.scrollHandler);
}
}
public removeScrollEventListener(): void {
if (!!this.rootElement && !!this.scrollHandler) {
this.rootElement.removeEventListener("scroll", this.scrollHandler);
if(!!this.rootElement.getElementsByTagName("form")[0]) {
this.rootElement.getElementsByTagName("form")[0].removeEventListener("scroll", this.scrollHandler);
}
if(!!this.css.rootWrapper) {
this.rootElement.getElementsByClassName(this.css.rootWrapper)[0]?.removeEventListener("scroll", this.scrollHandler);
}
Expand Down

0 comments on commit c0cd72e

Please sign in to comment.