Permalink
Browse files

Fixed the .isVisible() function of edges. Fixed show/hide bug

  • Loading branch information...
1 parent 347f8ff commit 839facad83601ea32ecbcd9ccec04d1e0c49f9e7 @vkaravir committed Mar 18, 2013
Showing with 23 additions and 5 deletions.
  1. +8 −0 doc/api.html
  2. +11 −4 src/datastructures.js
  3. +4 −1 src/graphicals.js
View
@@ -666,6 +666,12 @@ <h3 class="apimethod">.label()</h3>
<p>Returns the label attached to this edge.</p>
<h3 class="apimethod">.label(newLabel)</h3>
<p>Sets the value of the label attached to this edge.</p>
+<h3 class="apimethod">.show()</h3>
+<p>Shows this edge if it isn't visible already.</p>
+<h3 class="apimethod">.hide()</h3>
+<p>Hides this edge if it isn't hidden already.</p>
+<h3 class="apimethod">.isVisible()</h3>
+<p>Returns true if this edge is visible, false if hidden.</p>
<h2>Linked List API</h2>
@@ -1010,6 +1016,8 @@ <h3 class="apimethod">.show()</h3>
<p>Make the shape visible. Essentially the same as calling <code>.css({opacity: 1})</code>.</p>
<h3 class="apimethod">.hide()</h3>
<p>Make the shape invisible. Essentially the same as calling <code>.css({opacity: 0})</code>.</p>
+ <h3 class="apimethod">.isVisible()</h3>
+ <p>Return true if the shape is visible, false if hidden.</p>
<h3 class="apimethod">.rotate(deg)</h3>
<p>Rotates the object by the given amount of degrees around the center of the shape.</p>
<h3 class="apimethod">.scale(sx, sy), .scaleX(sx), .scaleY(sy)</h3>
View
@@ -157,12 +157,19 @@
this.g.rObj.remove();
};
edgeproto.hide = function(options) {
- this.g.hide(options);
- if (this._label) { this._label.hide(options); }
+ if (this.g.isVisible()) {
+ this.g.hide(options);
+ if (this._label) { this._label.hide(options); }
+ }
};
edgeproto.show = function(options) {
- this.g.show(options);
- if (this._label) { this._label.show(options); }
+ if (!this.g.isVisible()) {
+ this.g.show(options);
+ if (this._label) { this._label.show(options); }
+ }
+ };
+ edgeproto.isVisible = function() {
+ return this.g.isVisible();
};
edgeproto.label = function(newLabel, options) {
if (typeof newLabel === "undefined") {
View
@@ -6,7 +6,7 @@ if (typeof Raphael !== "undefined") { // only execute if Raphael is loaded
(function($, R) {
"use strict";
if (typeof JSAV === "undefined") { return; }
-
+
var common = {
// utility function that actually implements hide
// animated show function
@@ -17,6 +17,9 @@ if (typeof Raphael !== "undefined") { // only execute if Raphael is loaded
hide: function(options) {
this.css({"opacity": 0}, options);
},
+ isVisible: function(options) {
+ return (this.css("opacity") !== 0);
+ },
transform: function(transform, options) {
var oldTrans = this.rObj.transform();
if (this.jsav._shouldAnimate()) { // only animate when playing, not when recording

0 comments on commit 839faca

Please sign in to comment.