wipe function

547
1
07-12-2012 12:09 PM
NigelAlford
New Contributor III
I'm building a wipe function and I can't get it to wipe back in. I feel like I'm missing something small. I'm still new to javascript and dojo so any help would be great.

THANKS,

Wipe = function () 
    {
    if(LegendWrapper.display=!"none")
    {
        dojo.fx.wipeIn({
            node: "LegendWrapper",
            duration: 300
        }).play();
    }
    else{
    dojo.fx.wipeOut({
            node: "LegendWrapper",
            duration: 300
        }).play();
    }
    }
0 Kudos
1 Reply
SiqiLi
by Esri Contributor
Esri Contributor
I assume your 'LegendWrapper' is an esri.dijit.Legend object. I am able to wipe the legend dijit in and out. My Legend object's id is "basicWipeNode" which applies a the dom node.

Further sample of dojo.fx.wipeOut can be found at dojotoolkit.org. Hope this helps. Thanks.

Here is my codes:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
    <!--The viewport meta tag is used to improve the presentation and behavior of the samples
      on iOS devices-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
    <title>Map with legend</title>
    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.0/js/dojo/dijit/themes/claro/claro.css">
    <style>
      html, body { height: 98%; width: 98%; margin: 0; padding: 5px; }
      #rightPane{
        width:20%;
      }
      #legendPane{
        border: solid #97DCF2 1px;
      }
     
    </style>
    <script type="text/javascript">var djConfig = {parseOnLoad: true};</script>
    <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.0"></script>
    <script type="text/javascript">
      dojo.require("dijit.layout.BorderContainer");
      dojo.require("dijit.layout.ContentPane");
      dojo.require("dijit.layout.AccordionContainer");
      dojo.require("esri.map");
      dojo.require("esri.dijit.Legend");
      dojo.require("esri.layers.FeatureLayer");
   dojo.require("dojo.fx");
      dojo.require("dijit.form.Button");
     
      var map;
      function init() {
        var initialExtent = new esri.geometry.Extent({"xmin":-10753431,"ymin":4624151,"xmax":-10737799,"ymax":4635884,"spatialReference":{"wkid":102100}});
        map = new esri.Map("map", { extent: initialExtent});
       
        map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"));

        var rivers = new esri.layers.FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Hydrography/Watershed173811/MapServer/1", {
          mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
          outFields: ["*"]
        });
        
        //add the legend
        dojo.connect(map,'onLayersAddResult',function(results){
          var layerInfo = dojo.map(results, function(layer,index){
            return {layer:layer.layer,title:layer.layer.name};
          });
          if(layerInfo.length > 0){
            var legendDijit = new esri.dijit.Legend({
              map:map,
           id: "basicWipeNode",
              layerInfos:layerInfo
            },"legendDiv");
            legendDijit.startup();
          }
          
          wipeIt(); //wipe in
        });
       
        map.addLayers([rivers]);
        
        dojo.connect(map, 'onLoad', function(theMap) {
          dojo.connect(dijit.byId('map'), 'resize', map,map.resize);
        });
      }

     function wipeIt(){
 dojo.style("basicWipeNode", "display", "none");
 var wipeArgs = {
 node: "basicWipeNode",
 duration: 1000
 };
 dojo.fx.wipeIn(wipeArgs).play();
 }
 
 function wipeOut(){
 dojo.style("basicWipeNode", "height", "");
 dojo.style("basicWipeNode", "display", "block");
 var wipeArgs = {
 node: "basicWipeNode",
 duration: 1000
 };
 dojo.fx.wipeOut(wipeArgs).play();
 } 
   dojo.addOnLoad(init);
    </script>
  </head>
 
  <body class="claro">
    <div id="content" dojotype="dijit.layout.BorderContainer" design="headline" gutters="true" style="width: 100%; height: 100%; margin: 0;">
      <div id="rightPane" dojotype="dijit.layout.ContentPane" region="right">
        <div dojoType="dijit.layout.AccordionContainer">
          <div dojoType="dijit.layout.ContentPane" id="legendPane" title="Legend" selected="true" >
            <div id="legendDiv"></div>
          </div>
        </div>
      </div>
    
      <div id="map" dojotype="dijit.layout.ContentPane" region="center" style="overflow:hidden;"> 
        <button data-dojo-type="dijit.form.Button" id="basicWipeButton" onclick="wipeOut">Wipe It Out!</button>
      </div>
    </div>
  </body>
</html>
0 Kudos