コード例 #1
0
 public static void InitByRectangleWithNegativeSize() =>
 DomRect.FromRectangleF(new RectangleF(10, 30, -5, -7))
 .Assert(domRect => domRect.X == 10 &&
         domRect.Y == 30 &&
         domRect.Width == -5 &&
         domRect.Height == -7 &&
         domRect.Left == 5 &&
         domRect.Top == 23 &&
         domRect.Right == 10 &&
         domRect.Bottom == 30);
コード例 #2
0
 public static void InitByRectangle() =>
 DomRect.FromRectangleF(new RectangleF(1, 3, 5, 7))
 .Assert(domRect => domRect.X == 1 &&
         domRect.Y == 3 &&
         domRect.Width == 5 &&
         domRect.Height == 7 &&
         domRect.Left == 1 &&
         domRect.Top == 3 &&
         domRect.Right == 6 &&
         domRect.Bottom == 10);
コード例 #3
0
        private async void Resize(JsonElement e = default)
        {
            DomRect listRect = await JsInvokeAsync <DomRect>(JSInteropConstants.GetBoundingClientRect, _ref);

            if ((SlickWidth != (int)listRect.width && IsHorizontal) ||
                (SlickHeight != (int)listRect.height && !IsHorizontal) ||
                IsHorizontal && !string.IsNullOrEmpty(SlickListStyle) ||
                !IsHorizontal && string.IsNullOrEmpty(SlickListStyle))
            {
                SlickWidth  = (int)listRect.width;
                SlickHeight = (int)listRect.height;
                StateHasChanged();
            }
        }
コード例 #4
0
        protected override async Task OnAfterRenderAsync(bool first_render)
        {
            if (first_render)
            {
                await UpdateColorSwatch();
            }

            if (!UpdatingPicker)
            {
                // For some reason, it takes two rounds of updates
                // to get the controls to line up. So, we set a flag
                UpdatingPicker = true;

                DomRect swatch_rect = await DomUtils.GetBoundingClientRect(JS, SwatchId);

                float pick_x = swatch_rect.left;
                float pick_y = swatch_rect.top + 50;

                PickerStyle  = "background-color: #444;";
                PickerStyle += "width: 200px; height: 200px;";
                PickerStyle += "position: fixed;";
                PickerStyle += $"left: {pick_x}px;";
                PickerStyle += $"top: {pick_y}px;";

                StateHasChanged();
            }
            else
            {
                UpdatingPicker = false;

                // Whend the picker is shown for the first time, we register our body click handler
                if (PickerShown)
                {
                    PickerShown = false;

                    if (m_net_obj == null)
                    {
                        m_net_obj = DotNetObjectReference.Create(this);
                    }

                    await JS.InvokeAsync <object>("RegisterOutsideClickDetector", PickerId, m_net_obj, "OnOutsideClick");
                }
            }

            await Log("Swatch OnAfterRenderAsync Finished");
        }
コード例 #5
0
        private async void OnScroll(JsonElement obj)
        {
            _activeLink = null;
            _flatLinks.ForEach(l => l.Activate(false));

            int offset = OffsetBottom.HasValue ? OffsetBottom.Value : -OffsetTop.Value;

            foreach (var link in _flatLinks)
            {
                try
                {
                    DomRect hrefDom = await link.GetHrefDom();

                    if (hrefDom != null)
                    {
                        _linkTops[link.Href] = hrefDom.top + offset;
                    }
                }
                catch (Exception ex)
                {
                    _linkTops[link.Href] = 1;
                }
            }

            string activeKey = _linkTops.Where(p => (int)p.Value <= 0).OrderBy(p => p.Value).LastOrDefault().Key;

            if (!string.IsNullOrEmpty(activeKey))
            {
                _activeLink = _flatLinks.Single(l => l.Href == activeKey);
                await ActivateAsync(_activeLink, true);
            }

            if (Affix && _activeLink != null)
            {
                _ballClass = "ant-anchor-ink-ball visible";
                decimal top = (_activeLink.LinkDom.top - _selfDom.top) + _activeLink.LinkDom.height / 2 - 2;
                _ballStyle = $"top: {top}px;";
            }
            else
            {
                _ballClass = "ant-anchor-ink-ball";
                _ballStyle = string.Empty;
            }

            StateHasChanged();
        }
コード例 #6
0
        protected async override Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            DomRect listRect = await JsInvokeAsync <DomRect>(JSInteropConstants.getBoundingClientRect, _ref);

            if ((_slickWidth != (int)listRect.width && IsHorizontal) ||
                (_slickHeight != (int)listRect.height && !IsHorizontal) ||
                IsHorizontal && !string.IsNullOrEmpty(_slickListStyle) ||
                !IsHorizontal && string.IsNullOrEmpty(_slickListStyle))
            {
                _slickWidth  = (int)listRect.width;
                _slickHeight = (int)listRect.height;
                _totalWidth  = _slickWidth * (_slicks.Count * 2 + 1);
                _totalHeight = _slickHeight * (_slicks.Count * 2 + 1);
                if (Effect == CarouselEffect.ScrollX)
                {
                    if (IsHorizontal)
                    {
                        _trackStyle = $"width: {_totalWidth}px; opacity: 1; transform: translate3d(-{_slickWidth}px, 0px, 0px); transition: -webkit-transform 500ms ease 0s;";
                    }
                    else
                    {
                        _trackStyle = $"height: {_totalHeight}px; opacity: 1; transform: translate3d(0px, -{_slickHeight}px, 0px); transition: -webkit-transform 500ms ease 0s;";
                    }
                }
                else
                {
                    if (IsHorizontal)
                    {
                        _trackStyle = $"width: {_totalWidth}px; opacity: 1;";
                    }
                    else
                    {
                        _trackStyle = $"height: {_totalHeight}px; opacity: 1;";
                    }
                }

                _slickListStyle   = IsHorizontal ? string.Empty : $"height: {_slickHeight}px";
                _slickClonedStyle = $"width: {_slickWidth}px;";

                Activate(_slicks.IndexOf(_activeSlick));
                StateHasChanged();
            }
        }
コード例 #7
0
        protected override async Task OnFirstAfterRenderAsync()
        {
            _selfDom = await JsInvokeAsync <DomRect>(JSInteropConstants.getBoundingClientRect, _ink);

            _linkTops  = new Dictionary <string, decimal>();
            _flatLinks = FlatChildren();
            foreach (var link in _flatLinks)
            {
                _linkTops[link.Href] = 1;
            }

            if (GetCurrentAnchor != null)
            {
                AnchorLink link = _flatLinks.SingleOrDefault(l => l.Href == GetCurrentAnchor());
                if (link != null)
                {
                    try
                    {
                        DomRect hrefDom = await link.GetHrefDom(true);

                        if (hrefDom != null)
                        {
                            await ActivateAsync(link, true);

                            // the offset does not matter, since the dictionary's value will not change any more in case user set up GetCurrentAnchor
                            _linkTops[link.Href] = hrefDom.top;
                            StateHasChanged();
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }

            await base.OnFirstAfterRenderAsync();
        }
コード例 #8
0
        protected async override Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            DomRect listRect = await JsInvokeAsync <DomRect>(JSInteropConstants.getBoundingClientRect, _ref);

            if (_slickWidth != (int)listRect.width)
            {
                _slickWidth = (int)listRect.width;
                _totalWidth = _slickWidth * (_slicks.Count * 2 + 1);
                if (Effect == AntCarouselEffect.ScrollX)
                {
                    _trackStyle = $"width: {_totalWidth}px; opacity: 1; transform: translate3d(-{_slickWidth}px, 0px, 0px); transition: -webkit-transform 500ms ease 0s;";
                }
                else
                {
                    _trackStyle = $"width: {_totalWidth}px; opacity: 1;";
                }
                _slickClonedStyle = $"width: {_slickWidth}px;";

                StateHasChanged();
            }
        }