Survey.StylesManager.applyTheme("default");
var json = {
"logoPosition": "right",
"pages": [
{
"name": "page1",
"elements": [
{
"type": "matrix",
"name": "Quality",
"title": "Please indicate if you agree or disagree with the following statements",
"columns": [
{
"value": 1,
"text": "Strongly Disagree"
},
{
"value": 2,
"text": "Disagree"
},
{
"value": 3,
"text": "Neutral"
},
{
"value": 4,
"text": "Agree"
},
{
"value": 5,
"text": "Strongly Agree"
}
],
"rows": [
{
"value": "affordable",
"text": "Product is affordable"
},
{
"value": "does what it claims",
"text": "Product does what it claims"
},
{
"value": "better then others",
"text": "Product is better than other products on the market"
},
{
"value": "easy to use",
"text": "Product is easy to use"
}
]
}
]
},
{
"name": "page4",
"elements": [
{
"type": "rating",
"name": "question2",
"title": "How satisfied are you with the Product?",
"minRateDescription": "Not Satisfied",
"maxRateDescription": "Completely satisfied"
},
{
"type": "comment",
"name": "question4",
"title": "What would make you more satisfied with the Product?"
}
]
},
{
"name": "page2",
"elements": [
{
"type": "radiogroup",
"name": "price to competitors",
"title": "Compared to our competitors, do you feel the Product is",
"choices": [
"Less expensive",
"Priced about the same",
"More expensive",
"Not sure"
]
}
]
},
{
"name": "page3",
"elements": [
{
"type": "text",
"name": "email",
"title": "Thank you for taking our survey. Your survey is almost complete, please enter your email address in the box below if you wish to participate in our drawing, then press the 'Complete' button."
}
]
}
]
};
window.survey = new Survey.Model(json);
survey.onComplete.add(function(sender) {
document.querySelector('#surveyResult').textContent =
"Result JSON:\n" + JSON.stringify(sender.data, null, 3);
});
survey.render("surveyElement");
function animate(animitionType, duration) {
if (!duration) duration = 1000;
var element = document.getElementById("surveyElement");
$(element).velocity(animitionType, { duration: duration });
}
var doAnimantion = true;
survey.onCurrentPageChanging.add(function (sender, options) {
if (!doAnimantion) return;
options.allowChanging = false;
setTimeout(function () {
doAnimantion = false;
sender.currentPage = options.newCurrentPage;
doAnimantion = true;
}, 500);
animate("slideUp", 500);
});
survey.onCurrentPageChanged.add(function (sender) {
animate("slideDown", 500);
});
survey.onCompleting.add(function (sender, options) {
if (!doAnimantion) return;
options.allowComplete = false;
setTimeout(function () {
doAnimantion = false;
sender.doComplete();
doAnimantion = true;
}, 500);
animate("slideUp", 500);
});
animate("slideDown", 1000);
<!DOCTYPE html>
<html lang="en">
<head>
<title>Survey Animation, Knockoutjs Survey Library Example</title>
<meta name="viewport" content="width=device-width" />
<script src="https://unpkg.com/jquery"></script>
<script src="https://unpkg.com/knockout@3.5.1/build/output/knockout-latest.js"></script>
<script src="/DevBuilds/survey-core/survey.core.min.js"></script>
<script src="/DevBuilds/survey-core/survey.i18n.min.js"></script>
<script src="/DevBuilds/survey-knockout-ui/survey-knockout-ui.min.js"></script>
<link href="/DevBuilds/survey-core/survey.min.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" href="./index.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/velocity/1.1.0/velocity.min.js"></script>
</head>
<body style="margin: 0">
<div id="surveyElement" style="display:inline-block;width:100%;">
</div>
<div id="surveyResult"></div>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>
Help us serve you better by taking this brief survey.
We are interested to learn more about your
experience of using our libraries.
We'd really appreciate your feedback.
Start the SurveyApproximate time to complete: 2 min.