Skip to content

Commit

Permalink
more (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
hainm committed Aug 22, 2017
1 parent 606bd65 commit 61b1dcd
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 57 deletions.
2 changes: 1 addition & 1 deletion js/package.json
@@ -1,6 +1,6 @@
{
"name": "nglview-js-widgets",
"version": "0.5.4-dev.15",
"version": "0.5.4-dev.16",
"description": "nglview-js-widgets",
"author": "Hai Nguyen <hainm.comp@gmail.com>, Alexander Rose <alexander.rose@weirdbyte.de>",
"license": "MIT",
Expand Down
47 changes: 29 additions & 18 deletions js/src/widget_ngl.js
Expand Up @@ -216,12 +216,17 @@ var NGLView = widgets.DOMWidgetView.extend({
var that = this
var ngl_coordinate_resource = that.model.get("_ngl_coordinate_resource");
var ngl_msg_archive = that.model.get("_ngl_msg_archive");
var ngl_stage_params = that.model.get('_ngl_full_stage_parameters_embed');
var loadfile_list = [];

_.each(ngl_msg_archive, function(msg){
if (msg.methodName == 'loadFile'){
loadfile_list.push(that._get_loadFile_promise(msg));
}
});

console.log('ngl_stage_params', ngl_stage_params);

Promise.all(loadfile_list).then(function(compList){
var ngl_repr_dict = that.model.get('_ngl_repr_dict')
for (var index in ngl_repr_dict){
Expand All @@ -234,8 +239,12 @@ var NGLView = widgets.DOMWidgetView.extend({
}
}

that.stage.setParameters(ngl_stage_params);

var frame = 0;
var count = that.model.get("count");
var count = ngl_coordinate_resource['n_frames'];
delete ngl_coordinate_resource['n_frames'];

var play = function(){
that.$playerButton.text("pause");
that.playerInterval = setInterval(function(){
Expand All @@ -255,24 +264,26 @@ var NGLView = widgets.DOMWidgetView.extend({
}
}.bind(that);

that.$playerButton
.off('click')
.click(function(event) {
if (that.$playerButton.text() === "play") {
play();
} else if (that.$playerButton.text() === "pause") {
if (that.$playerButton){
that.$playerButton
.off('click')
.click(function(event) {
if (that.$playerButton.text() === "play") {
play();
} else if (that.$playerButton.text() === "pause") {
pause();
}
event; // to pass eslint
}.bind(that));
that.$playerSlider.slider({
max : count-1,
slide: function(event, ui) {
pause();
}
event; // to pass eslint
}.bind(that));

that.$playerSlider.slider({
slide: function(event, ui) {
pause();
that.updateCoordinatesFromDict(ngl_coordinate_resource, ui.value);
frame = ui.value;
}.bind(that)
})
that.updateCoordinatesFromDict(ngl_coordinate_resource, ui.value);
frame = ui.value;
}.bind(that)
})
}
});
},

Expand Down
2 changes: 1 addition & 1 deletion jslab/package.json
Expand Up @@ -17,7 +17,7 @@
"license": "MIT",
"dependencies": {
"@jupyter-widgets/jupyterlab-manager": "^0.25.11",
"nglview-js-widgets": "0.5.4-dev.15"
"nglview-js-widgets": "0.5.4-dev.16"
},
"jupyterlab": {
"extension": true
Expand Down
66 changes: 31 additions & 35 deletions nglview/static/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion nglview/static/index.js.map

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion nglview/widget.py
Expand Up @@ -28,7 +28,7 @@
from .remote_thread import RemoteCallThread

__all__ = ['NGLWidget', 'ComponentViewer']
__frontend_version__ = '0.5.4-dev.15' # must match to js/package.json and js/src/widget_ngl.js
__frontend_version__ = '0.5.4-dev.16' # must match to js/package.json and js/src/widget_ngl.js
_EXCLUDED_CALLBACK_AFTER_FIRING = {
'setUnSyncCamera', 'setSelector', 'setUnSyncFrame', 'setDelay',
'_downloadImage', '_exportImage'
Expand Down Expand Up @@ -117,6 +117,7 @@ class NGLWidget(DOMWidget):
# TODO: remove _parameters?
_parameters = Dict().tag(sync=False)
_ngl_full_stage_parameters = Dict().tag(sync=True)
_ngl_full_stage_parameters_embed = Dict().tag(sync=True)
_ngl_original_stage_parameters = Dict().tag(sync=True)
_coordinates_dict = Dict().tag(sync=False)
_camera_str = CaselessStrEnum(
Expand Down Expand Up @@ -227,12 +228,16 @@ def _set_serialization(self, frame_range=None):
else:
resource[t_index].append(encode_base64(
np.empty((0), dtype='f4')))
resource['n_frames'] = len(resource[0])

self._ngl_coordinate_resource = resource
self._ngl_full_stage_parameters_embed = self._ngl_full_stage_parameters

def _unset_serialization(self):
self._ngl_serialize = False
self._ngl_msg_archive = []
self._ngl_coordinate_resource = {}
self._ngl_full_stage_parameters_embed = {}

@property
def parameters(self):
Expand Down

0 comments on commit 61b1dcd

Please sign in to comment.