Repository: flex-asjs Updated Branches: refs/heads/feature-autobuild/example-maven-dirs 35e7acc0b -> 9b6e60cbb
Added ClippingViewport Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/043b092d Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/043b092d Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/043b092d Branch: refs/heads/feature-autobuild/example-maven-dirs Commit: 043b092d146e7fece8b9024b8705790e316256a2 Parents: f4caf2c Author: yishayw <yishayj...@hotmail.com> Authored: Wed Nov 9 09:38:10 2016 +0200 Committer: yishayw <yishayj...@hotmail.com> Committed: Wed Nov 9 09:38:10 2016 +0200 ---------------------------------------------------------------------- .../html/supportClasses/ClippingViewport.as | 137 +++++++++++++++++++ .../HTML/src/main/resources/basic-manifest.xml | 1 + 2 files changed, 138 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/043b092d/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ClippingViewport.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ClippingViewport.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ClippingViewport.as new file mode 100644 index 0000000..00b88c1 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ClippingViewport.as @@ -0,0 +1,137 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.supportClasses +{ + import org.apache.flex.core.IBead; + import org.apache.flex.core.IBeadLayout; + import org.apache.flex.core.IViewport; + import org.apache.flex.core.UIBase; + import org.apache.flex.geom.Size; + + COMPILE::JS + { + import org.apache.flex.core.IStrand; + } + COMPILE::SWF + { + import flash.geom.Rectangle; + } + + /** + * The ClippingViewport extends the Viewport class and makes + * sure that items extending outside the Container are hidden. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ClippingViewport extends Viewport implements IBead, IViewport + { + /** + * Constructor + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ClippingViewport() + { + } + + /** + * @flexjsignorecoercion HTMLElement + */ + COMPILE::JS + override public function set strand(value:IStrand):void + { + super.strand = value; + (contentView.element as HTMLElement).style.overflow = 'hidden'; + } + + private var viewportWidth:Number; + private var viewportHeight:Number; + + /** + * @copy org.apache.flex.core.IViewport + */ + override public function layoutViewportBeforeContentLayout(width:Number, height:Number):void + { + super.layoutViewportBeforeContentLayout(width, height); + viewportWidth = width; + viewportHeight = height; + } + + /** + * @copy org.apache.flex.core.IViewport + */ + override public function layoutViewportAfterContentLayout():Size + { + COMPILE::SWF + { + var contentSize:Size; + do + { + contentSize = super.layoutViewportAfterContentLayout(); + if (isNaN(viewportHeight)) + viewportHeight = contentSize.height; + if (isNaN(viewportWidth)) + viewportWidth = contentSize.width; + + var host:UIBase = UIBase(_strand); + var visibleWidth:Number; + var visibleHeight:Number; + + var needsLayout:Boolean = false; + // resize content area + if (!isNaN(visibleWidth) || !isNaN(visibleHeight)) + { + if (!isNaN(visibleWidth)) + needsLayout = visibleWidth != contentView.width; + if (!isNaN(visibleHeight)) + needsLayout = visibleHeight != contentView.height; + if (!isNaN(visibleWidth) && !isNaN(visibleHeight)) + contentArea.setWidthAndHeight(visibleWidth, visibleHeight, false); + else if (!isNaN(visibleWidth)) + contentArea.setWidth(visibleWidth, false); + else if (!isNaN(visibleHeight)) + contentArea.setHeight(visibleHeight, false); + } + if (needsLayout) + { + var layout:IBeadLayout = host.getBeadByType(IBeadLayout) as IBeadLayout; + layout.layout(); + } + } while (needsLayout); + + var rect:Rectangle = new Rectangle(0, 0, viewportWidth,viewportHeight); + contentArea.$sprite.scrollRect = rect; + return contentSize; + + } + COMPILE::JS + { + return new Size(contentView.width, contentView.height); + } + + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/043b092d/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 cf67089..7919e14 100644 --- a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml +++ b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml @@ -92,6 +92,7 @@ <component id="ImageAndTextButtonView" class="org.apache.flex.html.beads.ImageAndTextButtonView" /> --> <component id="ScrollingViewport" class="org.apache.flex.html.supportClasses.ScrollingViewport" /> + <component id="ClippingViewport" class="org.apache.flex.html.supportClasses.ClippingViewport" /> <component id="ArraySelectionModel" class="org.apache.flex.html.beads.models.ArraySelectionModel" /> <component id="ArrayListSelectionModel" class="org.apache.flex.html.beads.models.ArrayListSelectionModel" />