cordova - hide and show part of GEO sorted buttons list -


i busy days figure out following issue, hope here me.

the situation: iam building phonegap(build) application. on home screen have in total 12 buttons of same size different content. in first situation 4 nearest (based on geolocation) buttons allowed show themselves. (geoloaction works ready) after pushing button "show more" other 8 buttons can showed (then have total of 12).

i tried using javascript style.display="none" or "block" works 90% cause issue. example if button display.style="none" close user (location) not disappear in nearest 4 positions. if push button "show more" works. how write?

javascript sorting buttons on geolocation

javascript showing handeling ul sorting geolocation

   <script>      navigator.geolocation.watchposition(sortresults);         function sortresults(position) {      // grab current position      var latlon = new latlon(position.coords.latitude, position.coords.longitude);         var locations = document.getelementbyid('locations');      var locationlist = locations.queryselectorall('li');      var locationarray = array.prototype.slice.call(locationlist, 0);           locationarray.sort(function(a,b){        var loca  = a.getattribute('data-latlon').split(',');        var locb  = b.getattribute('data-latlon').split(',');           dista = latlon.distanceto(new latlon(number(loca[0]),number(loca[1])));        distb = latlon.distanceto(new latlon(number(locb[0]),number(locb[1])));        return dista - distb;  	    });         //reorder list      locations.innerhtml = "";      locationarray.foreach(function(el) {        locations.appendchild(el);      });     };    </script>

html button

<li id="but-pos1-12" data-latlon="">  <div class="col-3 col-m-4 col-mp-6">  <div class="but" id="but-pos12">  <a href="historie.html" class="but-link">  <span class="but-pont-name"></span><br><span class="but-pont-name2"></span>  <img src="img/boot.png" class="but-pont-img">  <div id="but-small-img-pos12" align="center">  <img src="" class="but-pont-small-img" id="pos12-1">  <img src="" class="but-pont-small-img" id="pos12-2">  <img src="" class="but-pont-small-img" id="pos12-3">  <img src="" class="but-pont-small-img" id="pos12-4">  <img src="" class="but-pont-small-img" id="pos12-5">  <img src="" class="but-pont-small-img" id="pos12-6">  <img src="" class="but-pont-small-img" id="pos12-7">  </a>  </div>  </div>  </div>  </li>

javascript showing , hiding

document.addeventlistener("deviceready", ondeviceready, false);  function ondeviceready(){    document.getelementbyid("but-anderepont-show").addeventlistener("click", showotherponts, false);  document.getelementbyid("but-anderepont-hide").addeventlistener("click", hideotherponts, false);      }  function hideotherponts(){  	  	document.getelementbyid("but-anderepont-hide").style.display = 'none';  	document.getelementbyid("but-anderepont-show").style.display = 'inline-block';  	document.getelementbyid("but-pos1-5").style.display = "none";  	document.getelementbyid("but-pos1-6").style.display = "none";  	document.getelementbyid("but-pos1-7").style.display = "none";  	document.getelementbyid("but-pos1-8").style.display = "none";  	document.getelementbyid("but-pos1-9").style.display = "none";  	document.getelementbyid("but-pos1-10").style.display = "none";  	document.getelementbyid("but-pos1-11").style.display = "none";  	document.getelementbyid("but-pos1-12").style.display = "none";  }    function showotherponts(){  	  	document.getelementbyid("but-anderepont-show").style.display = "none";  	document.getelementbyid("but-anderepont-hide").style.display = "inline-block";  	document.getelementbyid("but-pos1-5").style.display = "block";  	document.getelementbyid("but-pos1-6").style.display = "block";  	document.getelementbyid("but-pos1-7").style.display = "block";  	document.getelementbyid("but-pos1-8").style.display = "block";  	document.getelementbyid("but-pos1-9").style.display = "block";  	document.getelementbyid("but-pos1-10").style.display = "block";  	document.getelementbyid("but-pos1-11").style.display = "block";  	document.getelementbyid("but-pos1-12").style.display = "block";  }


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -