Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3ED10200BAD for ; Tue, 25 Oct 2016 11:42:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3D5AD160AE6; Tue, 25 Oct 2016 09:42:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5D995160AF3 for ; Tue, 25 Oct 2016 11:42:09 +0200 (CEST) Received: (qmail 16859 invoked by uid 500); 25 Oct 2016 09:42:08 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 16851 invoked by uid 99); 25 Oct 2016 09:42:08 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Oct 2016 09:42:08 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7B135DFE5C; Tue, 25 Oct 2016 09:42:08 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: yishayw@apache.org To: commits@flex.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: [flex-asjs] [refs/heads/refactor-sprite] - Positioning parameters of SVG element change depending on whether it's contained in a element or in a
. Setting both params should make it work in both cases. Date: Tue, 25 Oct 2016 09:42:08 +0000 (UTC) archived-at: Tue, 25 Oct 2016 09:42:10 -0000 Repository: flex-asjs Updated Branches: refs/heads/refactor-sprite 3f1df179c -> 0d3ba9491 Positioning parameters of SVG element change depending on whether it's contained in a element or in a
. Setting both params should make it work in both cases. Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/0d3ba949 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/0d3ba949 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/0d3ba949 Branch: refs/heads/refactor-sprite Commit: 0d3ba9491a60ab39235807268437986114678f8b Parents: 3f1df17 Author: yishayw Authored: Tue Oct 25 12:41:55 2016 +0300 Committer: yishayw Committed: Tue Oct 25 12:41:55 2016 +0300 ---------------------------------------------------------------------- .../flex/org/apache/flex/core/ImageViewBase.as | 2 +- .../src/main/flex/org/apache/flex/svg/Image.as | 55 ++++++++++++++++++-- .../flex/org/apache/flex/svg/beads/ImageView.as | 41 +++++++++++++++ 3 files changed, 93 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0d3ba949/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ImageViewBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ImageViewBase.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ImageViewBase.as index 264fb07..afc7def 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ImageViewBase.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ImageViewBase.as @@ -211,7 +211,7 @@ package org.apache.flex.core * @flexjsignorecoercion HTMLElement */ COMPILE::JS - private function sizeChangedHandler(event:Object):void + protected function sizeChangedHandler(event:Object):void { var host:UIBase = _strand as UIBase; var s:Object = host.positioner.style; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0d3ba949/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/Image.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/Image.as b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/Image.as index 0524e41..cd0729f 100644 --- a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/Image.as +++ b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/Image.as @@ -33,7 +33,7 @@ package org.apache.flex.svg public function Image() { super(); - } + } /** * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement @@ -43,8 +43,8 @@ package org.apache.flex.svg { element = document.createElementNS('http://www.w3.org/2000/svg', 'svg') as WrappedHTMLElement; element.flexjs_wrapper = this; - element.style.left = 0; - element.style.top = 0; + element.setAttribute('x', 0); + element.setAttribute('y', 0); //element.offsetParent = null; positioner = element; positioner.style.position = 'relative'; @@ -75,12 +75,59 @@ package org.apache.flex.svg { return _image; } - + + COMPILE::JS + override public function get transformElement():WrappedHTMLElement + { + return _image; + } + COMPILE::JS override public function applyImageData(binaryDataAsString:String):void { (_image as SVGImageElement).setAttributeNS('http://www.w3.org/1999/xlink','href', binaryDataAsString); } + COMPILE::JS + override public function setWidth(value:Number, noEvent:Boolean=false):void + { + super.setWidth(value, noEvent); + positioner.setAttribute("width", value); + } + COMPILE::JS + override public function setHeight(value:Number, noEvent:Boolean=false):void + { + super.setHeight(value, noEvent); + positioner.setAttribute("height", value); + } + + COMPILE::JS + override public function setX(value:Number):void + { + super.setX(value); + positioner.setAttribute("x", value); + + } + COMPILE::JS + override public function setY(value:Number):void + { + super.setY(value); + positioner.setAttribute("y", value); + + } + + COMPILE::JS + override public function set x(value:Number):void + { + super.x = value; + positioner.setAttribute("x", value); + } + + COMPILE::JS + override public function set y(value:Number):void + { + super.y = value; + positioner.setAttribute("y", value); + } } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0d3ba949/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/beads/ImageView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/beads/ImageView.as b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/beads/ImageView.as index 0f40093..8cbd789 100644 --- a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/beads/ImageView.as +++ b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/beads/ImageView.as @@ -20,6 +20,11 @@ package org.apache.flex.svg.beads { import org.apache.flex.core.ImageViewBase; + COMPILE::JS + { + import org.apache.flex.core.UIBase; + import org.apache.flex.core.ValuesManager; + } /** * The ImageView class creates the visual elements of the org.apache.flex.svg.Image component. @@ -42,5 +47,41 @@ package org.apache.flex.svg.beads public function ImageView() { } + + COMPILE::JS + override protected function sizeChangedHandler(event:Object):void + { + super.sizeChangedHandler(event); + var host:UIBase = _strand as UIBase; + + var left:* = ValuesManager.valuesImpl.getValue(host, "left"); + var right:* = ValuesManager.valuesImpl.getValue(host, "right"); + var l:Number = isNaN(left) ? NaN : left; + var r:Number = isNaN(right) ? NaN : right; + + var top:* = ValuesManager.valuesImpl.getValue(host, "top"); + var bottom:* = ValuesManager.valuesImpl.getValue(host, "bottom"); + var t:Number = isNaN(top) ? NaN : top; + var b:Number = isNaN(bottom) ? NaN : bottom; + + var p:Object = host.positioner; + + if (!isNaN(l) && + !isNaN(r)) { + // if just using size constraints and image will not shrink or grow + var computedWidth:Number = (host.positioner.offsetParent as HTMLElement).offsetWidth - + l - r; + p.setAttribute("width", computedWidth); + + } + if (!isNaN(t) && + !isNaN(b)) { + // if just using size constraints and image will not shrink or grow + var computedHeight:Number = (host.positioner.offsetParent as HTMLElement).offsetHeight - + t - b; + p.setAttribute("height", computedHeight); + } + } + } }