Commit 66485499 authored by Scott Wittenburg's avatar Scott Wittenburg

Allow clients to know when a render occurred that was not stale.

Change-Id: Ia3f3d4ac9e970f0827321329a9ac341f897453d2
parent a701e9c0
......@@ -177,6 +177,10 @@
// request another render to try to get the latest image.
if (res.stale === true) {
renderOnIdle();
} else {
container.trigger({
type: 'renderer-ready'
});
}
});
}
......
......@@ -537,6 +537,18 @@
throw "'session' must be provided within the option.";
}
function onReadyInternal() {
if(userReadyCallback.fn) {
// Providing just a short delay before triggering the "image-not-state"
// event provides a break in the action so that the browser can draw the
// image we just copied to the src attribute.
setTimeout(userReadyCallback.fn, 0);
if(userReadyCallback.once) {
userReadyCallback.fn = null;
}
}
}
// Create viewport
var config = $.extend({}, DEFAULT_VIEWPORT_OPTIONS, options),
session = options.session,
......@@ -547,6 +559,7 @@
onDoneQueue = [],
statisticManager = createStatisticManager(),
inSelectionMode = false,
userReadyCallback = { fn: null, once: false},
viewport = {
/**
* Update the active renderer to be something else.
......@@ -669,6 +682,14 @@
rendererContainer.trigger('clearCache');
},
/*
* Provide a function that will be called when
*/
onReady: function(readyCallback, once) {
userReadyCallback.fn = readyCallback;
userReadyCallback.once = once;
},
/**
* Attach viewport to a DOM element
*
......@@ -802,6 +823,9 @@
}
});
// Attach the on ready internal
rendererContainer.bind('renderer-ready', onReadyInternal);
// Create any renderer type that is available
for(var key in vtkWeb.ViewportFactory) {
try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment