flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yish...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - Add easing effect to accordion.
Date Wed, 16 Nov 2016 07:58:48 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 2deb36992 -> c4eb090f0


Add easing effect to accordion.


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

Branch: refs/heads/develop
Commit: c4eb090f0270e70bef60db375ffee34bb80c7e53
Parents: 2deb369
Author: yishayw <yishayjobs@hotmail.com>
Authored: Wed Nov 16 09:58:37 2016 +0200
Committer: yishayw <yishayjobs@hotmail.com>
Committed: Wed Nov 16 09:58:37 2016 +0200

----------------------------------------------------------------------
 .../main/flex/org/apache/flex/html/Accordion.as | 55 ++++++-----
 .../flex/html/beads/AccordionCollapseBead.as    |  2 +-
 .../html/beads/EasyAccordionCollapseBead.as     | 98 ++++++++++++++++++++
 .../HTML/src/main/resources/basic-manifest.xml  |  1 +
 4 files changed, 131 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c4eb090f/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Accordion.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Accordion.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Accordion.as
index 20e3f96..3076d0c 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Accordion.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Accordion.as
@@ -21,36 +21,36 @@ package org.apache.flex.html
 	import org.apache.flex.core.ValuesManager;
 	import org.apache.flex.html.beads.IAccordionCollapseBead;
 	
-
-    /**
-     *  The Accordion class used to display a list of collapsible components
+	
+	/**
+	 *  The Accordion class used to display a list of collapsible components
 	 *  All but the selected item are expected to be collapsed.
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10.2
-     *  @playerversion AIR 2.6
-     *  @productversion FlexJS 0.0
-     */    
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion FlexJS 0.0
+	 */    
 	public class Accordion extends List
 	{
 		private var _collapseBead:IAccordionCollapseBead;
-        /**
-         *  Constructor.
-         *  
-         *  @langversion 3.0
-         *  @playerversion Flash 10.2
-         *  @playerversion AIR 2.6
-         *  @productversion FlexJS 0.0
-         */
+		/**
+		 *  Constructor.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
 		public function Accordion()
 		{
 			super();
-			accordionCollapseBead; // make sure it's initialized
 		}
 		
 		override public function addedToParent():void
 		{
 			super.addedToParent();
+			accordionCollapseBead; // make sure it's initialized
 			if (selectedIndex < 0)
 			{
 				selectedIndex = 0;
@@ -61,19 +61,26 @@ package org.apache.flex.html
 		{
 			if (_collapseBead == null)
 			{
-				var c:Class = ValuesManager.valuesImpl.getValue(this, "iAccordionCollapseBead") as Class;
-				if (c)
+				_collapseBead = getBeadByType(IAccordionCollapseBead) as IAccordionCollapseBead;
+				if (_collapseBead == null)
 				{
+					var c:Class = ValuesManager.valuesImpl.getValue(this, "iAccordionCollapseBead") as Class;
 					if (c)
 					{
-						_collapseBead = (new c()) as IAccordionCollapseBead;
-						addBead(_collapseBead);
+						if (c)
+						{
+							_collapseBead = (new c()) as IAccordionCollapseBead;
+						}
 					}
 				}
 			}
+			if (_collapseBead)
+			{
+				addBead(_collapseBead);
+			}
 			return _collapseBead;
 		}
-
-				
+		
+		
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c4eb090f/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/AccordionCollapseBead.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/AccordionCollapseBead.as
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/AccordionCollapseBead.as
index 4222ab6..d666fc1 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/AccordionCollapseBead.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/AccordionCollapseBead.as
@@ -39,7 +39,7 @@ package org.apache.flex.html.beads
 			host.model.addEventListener("selectedIndexChanged", selectedIndexChangedHandler);
 		}
 		
-		private function get host():Accordion
+		protected function get host():Accordion
 		{
 			return _strand as Accordion;
 		}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c4eb090f/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
new file mode 100644
index 0000000..0d0702f
--- /dev/null
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/EasyAccordionCollapseBead.as
@@ -0,0 +1,98 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html.beads
+{
+	
+	import flash.events.IEventDispatcher;
+	
+	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.Parallel;
+	import org.apache.flex.effects.Resize;
+	import org.apache.flex.events.Event;
+	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;
+		public function EasyAccordionCollapseBead()
+		{
+			super();
+		}
+		
+		private function findPreviousNonCollapsed():ICollapsible
+		{
+			var n:int = view.dataGroup.numElements;
+			for (var i:int = 0; i < n; i++)
+			{
+				var collapsible:ICollapsible = view.dataGroup.getElementAt(i) as ICollapsible;
+				if (collapsible.collapsedHeight != (collapsible as ILayoutChild).height)
+				{
+					return collapsible;
+				}
+			}
+			return null;
+		}
+		
+		private function get view():IListView
+		{
+			return host.view as IListView;			
+		}
+		
+		override protected function selectedIndexChangedHandler(event:Event):void
+		{
+			var newChild:UIBase = view.dataGroup.getElementAt(host.selectedIndex) as UIBase;
+			var oldChild:UIBase = findPreviousNonCollapsed() as UIBase;
+			if (!newChild || !oldChild)
+			{
+				return;
+			}
+			var effect:Effect = getResize(newChild, oldChild);
+			effect.addEventListener(Effect.EFFECT_END, effectEndHandler);
+			layout.flexibleChild = newChild.id;
+			effect.play();
+		}
+		
+		private function get layout():IOneFlexibleChildLayout
+		{
+			return host.getBeadByType(IOneFlexibleChildLayout) as IOneFlexibleChildLayout;
+		}
+		
+		protected function effectEndHandler(event:Event):void
+		{
+			(event.target as IEventDispatcher).removeEventListener(Effect.EFFECT_END, effectEndHandler);
+			layout.layout();
+		}
+		
+		private function getResize(newChild:UIBase, oldChild:UIBase):Effect
+		{
+			var resizeNew:Resize = new Resize(newChild);
+			resizeNew.heightTo = oldChild.height;
+			var resizeOld:Resize = new Resize(oldChild);
+			resizeOld.heightTo = (oldChild as ICollapsible).collapsedHeight;
+			var parallel:Parallel = new Parallel();
+			parallel.children = [resizeNew, resizeOld];
+			return parallel;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c4eb090f/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
index dd713ca..b109ce5 100644
--- a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
@@ -74,6 +74,7 @@
     <component id="StringItemRenderer" class="org.apache.flex.html.supportClasses.StringItemRenderer"/>
     <component id="AccordionItemRenderer" class="org.apache.flex.html.supportClasses.AccordionItemRenderer"/>
     <component id="AccordionCollapseBead" class="org.apache.flex.html.beads.AccordionCollapseBead"/>
+    <component id="EasyAccordionCollapseBead" class="org.apache.flex.html.beads.EasyAccordionCollapseBead"/>
     <component id="TreeItemRenderer" class="org.apache.flex.html.supportClasses.TreeItemRenderer"/>
     <component id="DataItemRenderer" class="org.apache.flex.html.supportClasses.DataItemRenderer"/>
     <component id="MXMLItemRenderer" class="org.apache.flex.html.supportClasses.MXMLItemRenderer"/>


Mime
View raw message