Skip to content

Commit

Permalink
Merge branch 'asterixslashstar-animation-duration' into unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
hasanbalci committed Jul 30, 2019
2 parents 5385d84 + cdc8750 commit 54c71ef
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 31 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Notice that following events are performed for *each* node that is collapsed/exp
// recommended usage: use cose-bilkent layout with randomize: false to preserve mental map upon expand/collapse
fisheye: true, // whether to perform fisheye view after expand/collapse you can specify a function too
animate: true, // whether to animate on drawing changes you can specify a function too
animationDuration: 1000, // when animate is true, the duration in milliseconds of the animation
ready: function () { }, // callback when expand/collapse initialized
undoable: true, // and if undoRedoExtension exists,

Expand Down
33 changes: 17 additions & 16 deletions cytoscape-expand-collapse.js

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions src/expandCollapseUtilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ return {
var node = nodes[0];
if (node._private.data.collapsedChildren != null) {
// Expand the given node the third parameter indicates that the node is simple which ensures that fisheye parameter will be considered
this.expandNode(node, options.fisheye, true, options.animate, options.layoutBy);
this.expandNode(node, options.fisheye, true, options.animate, options.layoutBy, options.animationDuration);
}
}
else {
Expand All @@ -160,7 +160,7 @@ return {
* in a batch.
*/
cy.startBatch();
this.simpleCollapseGivenNodes(nodes, options);
this.simpleCollapseGivenNodes(nodes/*, options*/);
cy.endBatch();

nodes.trigger("position"); // position not triggered by default when collapseNode is called
Expand Down Expand Up @@ -220,10 +220,10 @@ return {
* applyFishEyeView parameter then the state of view port is to be changed to have extra space on the screen (if needed) before appliying the
* fisheye view.
*/
expandNode: function (node, applyFishEyeView, single, animate, layoutBy) {
expandNode: function (node, applyFishEyeView, single, animate, layoutBy, animationDuration) {
var self = this;

var commonExpandOperation = function (node, applyFishEyeView, single, animate, layoutBy) {
var commonExpandOperation = function (node, applyFishEyeView, single, animate, layoutBy, animationDuration) {
if (applyFishEyeView) {

node._private.data['width-before-fisheye'] = node._private.data['size-before-collapse'].w;
Expand All @@ -232,7 +232,7 @@ return {
// Fisheye view expand the node.
// The first paramter indicates the node to apply fisheye view, the third parameter indicates the node
// to be expanded after fisheye view is applied.
self.fishEyeViewExpandGivenNode(node, single, node, animate, layoutBy);
self.fishEyeViewExpandGivenNode(node, single, node, animate, layoutBy, animationDuration);
}

// If one of these parameters is truthy it means that expandNodeBaseFunction is already to be called.
Expand Down Expand Up @@ -279,10 +279,10 @@ return {
pan: viewPort.pan,
zoom: viewPort.zoom,
complete: function () {
commonExpandOperation(node, applyFishEyeView, single, animate, layoutBy);
commonExpandOperation(node, applyFishEyeView, single, animate, layoutBy, animationDuration);
}
}, {
duration: 1000
duration: animationDuration || 1000
});
}
else {
Expand All @@ -294,7 +294,7 @@ return {

// If animating is not true we need to call commonExpandOperation here
if (!animating) {
commonExpandOperation(node, applyFishEyeView, single, animate, layoutBy);
commonExpandOperation(node, applyFishEyeView, single, animate, layoutBy, animationDuration);
}

//return the node to undo the operation
Expand Down Expand Up @@ -350,7 +350,7 @@ return {
* Apply fisheye view to the given node. nodeToExpand will be expanded after the operation.
* The other parameter are to be passed by parameters directly in internal function calls.
*/
fishEyeViewExpandGivenNode: function (node, single, nodeToExpand, animate, layoutBy) {
fishEyeViewExpandGivenNode: function (node, single, nodeToExpand, animate, layoutBy, animationDuration) {
var siblings = this.getSiblings(node);

var x_a = this.xPositionInParent(node);
Expand Down Expand Up @@ -441,7 +441,7 @@ return {
}

// Move the sibling in the special way
this.fishEyeViewMoveNode(sibling, T_x, T_y, nodeToExpand, single, animate, layoutBy);
this.fishEyeViewMoveNode(sibling, T_x, T_y, nodeToExpand, single, animate, layoutBy, animationDuration);
}

// If there is no sibling call expand node base function here else it is to be called one of fishEyeViewMoveNode() calls
Expand All @@ -451,7 +451,7 @@ return {

if (node.parent()[0] != null) {
// Apply fisheye view to the parent node as well ( If exists )
this.fishEyeViewExpandGivenNode(node.parent()[0], single, nodeToExpand, animate, layoutBy);
this.fishEyeViewExpandGivenNode(node.parent()[0], single, nodeToExpand, animate, layoutBy, animationDuration);
}

return node;
Expand All @@ -472,7 +472,7 @@ return {
* Move node operation specialized for fish eye view expand operation
* Moves the node by moving its descandents. Movement is animated if both single and animate flags are truthy.
*/
fishEyeViewMoveNode: function (node, T_x, T_y, nodeToExpand, single, animate, layoutBy) {
fishEyeViewMoveNode: function (node, T_x, T_y, nodeToExpand, single, animate, layoutBy, animationDuration) {
var childrenList = cy.collection();
if(node.isParent()){
childrenList = node.children(":visible");
Expand Down Expand Up @@ -504,13 +504,13 @@ return {

}
}, {
duration: 1000
duration: animationDuration || 1000
});
}
}
else {
for (var i = 0; i < childrenList.length; i++) {
this.fishEyeViewMoveNode(childrenList[i], T_x, T_y, nodeToExpand, single, animate, layoutBy);
this.fishEyeViewMoveNode(childrenList[i], T_x, T_y, nodeToExpand, single, animate, layoutBy, animationDuration);
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

// set all options at once
api.setOptions = function(opts) {
setScratch(cy, 'options', options);
setScratch(cy, 'options', opts);
};

// set the option whose name is given
Expand Down Expand Up @@ -226,6 +226,7 @@
layoutBy: null, // for rearrange after expand/collapse. It's just layout options or whole layout function. Choose your side!
fisheye: true, // whether to perform fisheye view after expand/collapse you can specify a function too
animate: true, // whether to animate on drawing changes you can specify a function too
animationDuration: 1000, // when animate is true, the duration in milliseconds of the animation
ready: function () { }, // callback when expand/collapse initialized
undoable: true, // and if undoRedoExtension exists,

Expand Down

0 comments on commit 54c71ef

Please sign in to comment.