Add goal checking on user clicks
This commit is contained in:
parent
2f220eb007
commit
e30c51e145
1 changed files with 8 additions and 0 deletions
|
@ -35,6 +35,8 @@ function receiveMessage(event) {
|
||||||
case 'create':
|
case 'create':
|
||||||
create(_.pick(data, 'dom', 'styles', 'scripts'));
|
create(_.pick(data, 'dom', 'styles', 'scripts'));
|
||||||
checkGoals(data.goals, source, origin);
|
checkGoals(data.goals, source, origin);
|
||||||
|
$('body').first().off('click', checkRememberedGoals);
|
||||||
|
$('body').first().on('click', checkRememberedGoals);
|
||||||
break;
|
break;
|
||||||
case 'update':
|
case 'update':
|
||||||
if (virtualDom)
|
if (virtualDom)
|
||||||
|
@ -108,7 +110,13 @@ function update(options) {
|
||||||
virtualScripts = scripts;
|
virtualScripts = scripts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var lastGoalArgs = [];
|
||||||
|
function checkRememberedGoals() {
|
||||||
|
checkGoals.apply(this, lastGoalArgs);
|
||||||
|
}
|
||||||
|
|
||||||
function checkGoals(goals, source, origin) {
|
function checkGoals(goals, source, origin) {
|
||||||
|
lastGoalArgs = [goals, source, origin]; // Memoize for checkRememberedGoals
|
||||||
// Check right now and also in one second, since our 1-second CSS transition might be affecting things until it is done.
|
// Check right now and also in one second, since our 1-second CSS transition might be affecting things until it is done.
|
||||||
doCheckGoals(goals, source, origin);
|
doCheckGoals(goals, source, origin);
|
||||||
_.delay(function() { doCheckGoals(goals, source, origin); }, 1001);
|
_.delay(function() { doCheckGoals(goals, source, origin); }, 1001);
|
||||||
|
|
Reference in a new issue