flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yish...@apache.org
Subject [5/6] git commit: [flex-asjs] [refs/heads/develop] - Some improvements on easy renderer. An improved version will probably use layout to create the effect.
Date Mon, 21 Nov 2016 11:32:01 GMT
Some improvements on easy renderer. An improved version will probably use layout to create
the effect.


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/2915ddf4
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/2915ddf4
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/2915ddf4

Branch: refs/heads/develop
Commit: 2915ddf4d8e1cafc278d22a522c32fcba07d8f67
Parents: ec4fe07
Author: yishayw <yishayjobs@hotmail.com>
Authored: Mon Nov 21 13:26:01 2016 +0200
Committer: yishayw <yishayjobs@hotmail.com>
Committed: Mon Nov 21 13:26:01 2016 +0200

----------------------------------------------------------------------
 .../html/beads/EasyAccordionCollapseBead.as     | 48 +++++++++++++++-----
 1 file changed, 36 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/2915ddf4/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/EasyAccordionCollapseBead.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/EasyAccordionCollapseBead.as
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/EasyAccordionCollapseBead.as
index 4e01074..ec2098b 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/EasyAccordionCollapseBead.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/EasyAccordionCollapseBead.as
@@ -20,20 +20,23 @@ package org.apache.flex.html.beads
 {
 	
 	import org.apache.flex.core.ILayoutChild;
-	import org.apache.flex.core.IStrand;
 	import org.apache.flex.core.UIBase;
 	import org.apache.flex.effects.Effect;
+	import org.apache.flex.effects.IEffect;
 	import org.apache.flex.effects.Parallel;
 	import org.apache.flex.effects.Resize;
+	import org.apache.flex.effects.Tween;
 	import org.apache.flex.events.Event;
-	import org.apache.flex.events.IEventDispatcher;
+	import org.apache.flex.events.ValueEvent;
 	import org.apache.flex.html.beads.layouts.IOneFlexibleChildLayout;
 	import org.apache.flex.html.supportClasses.ICollapsible;
 	
 	public class EasyAccordionCollapseBead extends AccordionCollapseBead
 	{
-		private var _strand:IStrand;
-		private var lastSelectedIndex:int = -1;
+		private var newChild:UIBase;
+		private var oldChild:UIBase;
+		private var resizeNew:Resize;
+		private var resizeOld:Resize;
 		public function EasyAccordionCollapseBead()
 		{
 			super();
@@ -60,13 +63,13 @@ package org.apache.flex.html.beads
 		
 		override protected function selectedIndexChangedHandler(event:Event):void
 		{
-			var newChild:UIBase = view.dataGroup.getElementAt(host.selectedIndex) as UIBase;
-			var oldChild:UIBase = findPreviousNonCollapsed() as UIBase;
+			newChild = view.dataGroup.getElementAt(host.selectedIndex) as UIBase;
+			oldChild = findPreviousNonCollapsed() as UIBase;
 			if (!newChild || !oldChild)
 			{
 				return;
 			}
-			var effect:Effect = getResize(newChild, oldChild);
+			var effect:IEffect = getResize(newChild, oldChild);
 			effect.addEventListener(Effect.EFFECT_END, effectEndHandler);
 			layout.flexibleChild = newChild.id;
 			effect.play();
@@ -74,24 +77,45 @@ package org.apache.flex.html.beads
 		
 		private function get layout():IOneFlexibleChildLayout
 		{
-			return host.getBeadByType(IOneFlexibleChildLayout) as IOneFlexibleChildLayout;
+			return (view as AccordionView).layout;
 		}
 		
 		protected function effectEndHandler(event:Event):void
 		{
-			(event.target as IEventDispatcher).removeEventListener(Effect.EFFECT_END, effectEndHandler);
+			var parallel:Parallel = event.target as Parallel;
+			parallel.removeEventListener(Effect.EFFECT_END, effectEndHandler);
+			resizeNew.removeEventListener(Tween.TWEEN_UPDATE, newTweenUpdateHandler);
+			resizeOld.removeEventListener(Tween.TWEEN_UPDATE, oldTweenUpdateHandler);
+			resizeNew = null;
+			resizeOld = null;
+			newChild = null;
+			oldChild = null;
 			layout.layout();
 		}
 		
-		private function getResize(newChild:UIBase, oldChild:UIBase):Effect
+		private function getResize(newChild:UIBase, oldChild:UIBase):IEffect
 		{
-			var resizeNew:Resize = new Resize(newChild);
+			resizeNew = new Resize(newChild);
+//			resizeNew.duration = 3000;
+			resizeNew.addEventListener(Tween.TWEEN_UPDATE, newTweenUpdateHandler);
 			resizeNew.heightTo = oldChild.height;
-			var resizeOld:Resize = new Resize(oldChild);
+			resizeOld = new Resize(oldChild);
+//			resizeOld.duration = 3000;
+			resizeOld.addEventListener(Tween.TWEEN_UPDATE, oldTweenUpdateHandler);
 			resizeOld.heightTo = (oldChild as ICollapsible).collapsedHeight;
 			var parallel:Parallel = new Parallel();
 			parallel.children = [resizeNew, resizeOld];
 			return parallel;
 		}
+		
+		protected function oldTweenUpdateHandler(event:ValueEvent):void
+		{
+			oldChild.dispatchEvent(new Event("layoutNeeded"));
+		}
+		
+		protected function newTweenUpdateHandler(event:ValueEvent):void
+		{
+			newChild.dispatchEvent(new Event("layoutNeeded"));
+		}
 	}
 }
\ No newline at end of file


Mime
View raw message