Hi Piotr, Harbs,
Today I hope to create another bead that adjusts the padding of a container according to the scrollbar width, when a scrollbar appears. That was the use-case that motivated this. I think it’s ok to initialize the member to NaN. It will be assigned a number when the bead is added. Hopefully it’ll be clearer later today. Thanks. ________________________________ From: Piotr Zarzycki <[email protected]> Sent: Sunday, November 12, 2017 9:29:03 PM To: [email protected] Subject: Re: [royale-asjs] branch develop updated: Allow detection of default scrollbar width Ok. Just thought that by adding this line there is document.body.appendChild (outerDiv); that there is something more happen. The undefined for Number is acceptable for you at the beginning ? Just asking I don't see anything wrong here. :) Thanks, Piotr 2017-11-12 20:20 GMT+01:00 Harbs <[email protected]>: > I think the only thing the bead does is calculates what the width of a > scrollbar will be *if it’s visible*. > > The actual logic of setting the width of a component must be set > separately. > > > > On Nov 12, 2017, at 6:24 PM, Piotr Zarzycki <[email protected]> > wrote: > > > > Hi Yishay, > > > > I like that bead. Just quick question. This class resolves some problems > > with scroll bar for whole document. Am I thinking correctly? Can we have > > such problems for scrollbars in nested elements where scrollbar appears ? > > > > Thanks, Piotr > > > > On Sun, Nov 12, 2017, 16:19 <[email protected]> wrote: > > > >> This is an automated email from the ASF dual-hosted git repository. > >> > >> yishayw pushed a commit to branch develop > >> in repository https://gitbox.apache.org/repos/asf/royale-asjs.git > >> > >> > >> The following commit(s) were added to refs/heads/develop by this push: > >> new 200d4f0 Allow detection of default scrollbar width > >> new 2f0b056 Merge branch 'develop' of > >> https://github.com/apache/royale-asjs into develop > >> 200d4f0 is described below > >> > >> commit 200d4f097254163100c646192678bdaf112030c2 > >> Author: DESKTOP-RH4S838\Yishay <[email protected]> > >> AuthorDate: Sun Nov 12 17:18:31 2017 +0200 > >> > >> Allow detection of default scrollbar width > >> --- > >> .../Basic/src/main/resources/basic-manifest.xml | 2 + > >> .../apache/royale/html/beads/GetScrollbarWidth.as | 71 > >> ++++++++++++++++++++++ > >> 2 files changed, 73 insertions(+) > >> > >> diff --git > >> a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml > >> b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml > >> index 4adafe9..90b72b3 100644 > >> --- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml > >> +++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml > >> @@ -108,6 +108,8 @@ > >> <component id="HRuleView" > >> class="org.apache.royale.html.beads.HRuleView" /> > >> <component id="VRuleView" > >> class="org.apache.royale.html.beads.VRuleView" /> > >> --> > >> + > >> + <component id="GetScrollbarWidth" > >> class="org.apache.royale.html.beads.GetScrollbarWidth"/> > >> <component id="UnselectableElementBead" > >> class="org.apache.royale.html.beads.UnselectableElementBead"/> > >> <component id="DisableBead" > >> class="org.apache.royale.html.beads.DisableBead" /> > >> <component id="DisabledAlphaBead" > >> class="org.apache.royale.html.beads.DisabledAlphaBead" /> > >> diff --git > >> a/frameworks/projects/Basic/src/main/royale/org/apache/ > royale/html/beads/GetScrollbarWidth.as > >> b/frameworks/projects/Basic/src/main/royale/org/apache/ > royale/html/beads/GetScrollbarWidth.as > >> new file mode 100644 > >> index 0000000..91f546e > >> --- /dev/null > >> +++ > >> b/frameworks/projects/Basic/src/main/royale/org/apache/ > royale/html/beads/GetScrollbarWidth.as > >> @@ -0,0 +1,71 @@ > >> > >> +/////////////////////////////////////////////////////////// > ///////////////////// > >> +// > >> +// 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.royale.html.beads > >> +{ > >> + import org.apache.royale.core.IBead; > >> + import org.apache.royale.core.IStrand; > >> + COMPILE::JS > >> + { > >> + import org.apache.royale.core.WrappedHTMLElement; > >> + } > >> + > >> + /** > >> + * The GetScrollbarWidth class detects the browser's default > >> + * scrollbar width. This can be useful when changing the > viewport > >> + * width to avoid it being obstructed by the scrollbar. > >> + * > >> + * @langversion 3.0 > >> + * @playerversion Flash 10.2 > >> + * @playerversion AIR 2.6 > >> + * @productversion Royale 0.9 > >> + */ > >> + public class GetScrollbarWidth implements IBead > >> + { > >> + private var _scrollbarWidth:Number; > >> + > >> + public function GetScrollbarWidth() > >> + { > >> + } > >> + > >> + /** > >> + * @royaleignorecoercion org.apache.royale.core. > WrappedHTMLElement > >> + */ > >> + public function set strand (value:IStrand):void > >> + { > >> + COMPILE::JS > >> + { > >> + var outerDiv:WrappedHTMLElement = > >> document.createElement("div") as WrappedHTMLElement; > >> + document.body.appendChild(outerDiv); > >> + outerDiv.style.overflow = "scroll"; > >> + outerDiv.style.width = "50px"; > >> + var innerDiv:WrappedHTMLElement = > >> document.createElement("div") as WrappedHTMLElement; > >> + innerDiv.style.width = "100%"; > >> + outerDiv.appendChild(innerDiv); > >> + _scrollbarWidth = outerDiv.offsetWidth - > >> innerDiv.offsetWidth; > >> + document.body.removeChild(outerDiv); > >> + } > >> + } > >> + > >> + public function get scrollbarWidth():Number > >> + { > >> + return _scrollbarWidth; > >> + } > >> + } > >> +} > >> + > >> > >> -- > >> To stop receiving notification emails like this one, please contact > >> ['"[email protected]" <[email protected]>']. > >> > > -- Piotr Zarzycki Patreon: *https://www.patreon.com/piotrzarzycki <https://www.patreon.com/piotrzarzycki>*
