adding preloading

This commit is contained in:
Josh de Leeuw 2013-11-12 12:46:21 -05:00
parent 93e2ec17bc
commit 51020fea6b

View File

@ -1,5 +1,6 @@
<!doctype html>
<html>
<head>
<title>jspsych-text plugin example</title>
<!-- jQuery -->
@ -9,23 +10,43 @@
<script src="scripts/plugins/jspsych-animation.js"></script>
<!-- style -->
<style>
#jspsych_target { margin: 50px auto 50px auto; width: 600px; font-size:18px; text-align: center;}
#instructions { text-align: left; }
pre { text-align: left; }
#jspsych_target {
margin: 50px auto 50px auto;
width: 600px;
font-size:18px;
text-align: center;
}
#instructions {
text-align: left;
}
pre {
text-align: left;
}
</style>
</head>
<body>
<div id="jspsych_target">
</div>
<div id="jspsych_target"></div>
</body>
<script type="text/javascript">
// declare variable to hold animation sequence
var animation_sequence = ["img/face_1.jpg", "img/face_2.jpg", "img/face_3.jpg", "img/face_4.jpg", "img/face_3.jpg", "img/face_2.jpg"];
// create animation block for jspsych
var animation_block = {type:'animation', stimuli: [animation_sequence], repetitions:3};
var animation_block = {
type: 'animation',
stimuli: [animation_sequence],
repetitions: 3
};
// launch jspsych experiment
// preload images for animation sequence
// call start() when loading is complete
jsPsych.preloadImage(animation_sequence, start)
// function to launch jspsych experiment
// putting this in a function so that it only gets called once all the
// images are loaded using preloadImages
function start() {
jsPsych.init({
display_element: $('#jspsych_target'),
experiment_structure: [animation_block],
@ -35,5 +56,7 @@
}));
}
});
}
</script>
</html>