Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The first thing I did was to add an id to your buttons, as we need to know which type we want:</p> <pre><code>&lt;button id="A"&gt;Type А&lt;/button&gt; &lt;button id="B"&gt;Type B&lt;/button&gt; &lt;button id="C"&gt;Type C&lt;/button&gt; </code></pre> <p>Next I find the id of the button clicked:</p> <pre><code>// get id of button which was clicked var type = this.id; </code></pre> <p>Then I create a temporary set to hold the cottages which are of that type:</p> <pre><code>// create temporary set var set = canvas.set(); </code></pre> <p>Then in your loop, I find the cottage type that is equal to the clicked type, and add to temporary set</p> <pre><code>// loop all cottages and find the type we want c.forEach(function(el){ // put cottages in the temp set if(el.data("type") == type){ set.push(el); } }); </code></pre> <p>And finally animate this temporary set</p> <pre><code>// animate this set set.animate({fill: '#55bfe1', opacity: 1}, speed_anim_in); </code></pre> <p>I have a fiddle for you - <a href="http://jsfiddle.net/5BYK6/1/" rel="nofollow">http://jsfiddle.net/5BYK6/1/</a></p> <p><strong>EDIT</strong></p> <p>Ok I have added the following:</p> <pre><code>// fade any previous set if(prevSet) { prevSet.animate({opacity: 0}, speed_anim_out); } // store current set to remove later prevSet = set; </code></pre> <p>Basically we store the previous set we created, and check if there is one that exists in prevSet, we animate to opacity: 0, using your speed_anim_out variable.</p> <p>See updated fiddle for this <a href="http://jsfiddle.net/5BYK6/2/" rel="nofollow">http://jsfiddle.net/5BYK6/2/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload