Răsfoiți Sursa

Added animation when selecting locations.

Alan Lam 8 ani în urmă
părinte
comite
c5953b350c
1 a modificat fișierele cu 47 adăugiri și 32 ștergeri
  1. 47 32
      public/js/app-project-form.js

+ 47 - 32
public/js/app-project-form.js

@@ -9,42 +9,57 @@ $(function() {
 
 function handleSelectButton() {
 
-	$(this).text("Deselect");
-	$(this).removeClass("btn-outline-success");
-	$(this).addClass("btn-outline-danger");
-	let lgi = $(this).closest(".list-group-item").detach();
-	$("#selected-locations-list-group").append(lgi);
-	let lgis = $("#selected-locations-list-group .list-group-item");
-	lgis.sort(function(a, b) {
-		let aName = $(a).data("name").toLowerCase();
-		let bName = $(b).data("name").toLowerCase();
-
-		if(aName == bName) return 0;
-		return (aName > bName) ? 1 : -1;
-	}).detach();
-	$("#selected-locations-list-group").append(lgis);
-	refreshLocationAlerts();
-	refreshLocationIds();
+	let lgi = $(this).closest(".list-group-item");
+	let button = this;
+
+	lgi.slideUp("fast", function() {
+
+		$(button).text("Deselect");
+		$(button).removeClass("btn-outline-success");
+		$(button).addClass("btn-outline-danger");
+		lgi.detach();
+		$("#selected-locations-list-group").append(lgi);
+		let lgis = $("#selected-locations-list-group .list-group-item");
+		lgis.sort(function(a, b) {
+			let aName = $(a).data("name").toLowerCase();
+			let bName = $(b).data("name").toLowerCase();
+
+			if(aName == bName) return 0;
+			return (aName > bName) ? 1 : -1;
+		}).detach();
+		$("#selected-locations-list-group").append(lgis);
+		lgi.slideDown("fast");
+		refreshLocationAlerts();
+		refreshLocationIds();
+	});
 }
 
 function handleDeselectButton() {
-	$(this).text("Select");
-	$(this).removeClass("btn-outline-danger");
-	$(this).addClass("btn-outline-success");
-	let lgi = $(this).closest(".list-group-item").detach();
-	$("#not-selected-locations-list-group").append(lgi);
-	let lgis = $("#not-selected-locations-list-group .list-group-item");
-	lgis.sort(function(a, b) {
-
-		let aName = $(a).data("name").toLowerCase();
-		let bName = $(b).data("name").toLowerCase();
-
-		if(aName == bName) return 0;
-		return (aName > bName) ? 1 : -1;
+
+	let lgi = $(this).closest(".list-group-item");
+	let button = this;
+
+	lgi.slideUp("fast", function() {
+		$(button).text("Select");
+		$(button).removeClass("btn-outline-danger");
+		$(button).addClass("btn-outline-success");
+		lgi.detach();
+		$("#not-selected-locations-list-group").append(lgi);
+		let lgis = $("#not-selected-locations-list-group .list-group-item");
+		lgis.sort(function(a, b) {
+
+			let aName = $(a).data("name").toLowerCase();
+			let bName = $(b).data("name").toLowerCase();
+
+			if(aName == bName) return 0;
+			return (aName > bName) ? 1 : -1;
+		});
+		$("#not-selected-locations-list-group").append(lgis);
+		lgi.slideDown("fast");
+		refreshLocationAlerts();
+		refreshLocationIds();
 	});
-	$("#not-selected-locations-list-group").append(lgis);
-	refreshLocationAlerts();
-	refreshLocationIds();
+
 }
 
 function refreshLocationIds() {