Example #1
0
 public Card(IComponent content)
 {
     InnerElement   = Div(_("tss-card"), content.Render());
     _cardContainer = Div(_("tss-card-container"), InnerElement);
     DomObserver.WhenMounted(InnerElement, () => InnerElement.classList.add("tss-ismounted"));
     AttachClick();
 }
Example #2
0
        private HTMLDivElement GetAnimatedItem(IComponent component, bool isTitle, bool grow = false, string customPadding = "")
        {
            if (!((component as dynamic).StackItem is HTMLDivElement item))
            {
                item = Div(_(isTitle ? "tss-sectionstack-title tss-stack-item tss-sectionstack-item" : "tss-sectionstack-card tss-stack-item tss-sectionstack-item", styles: s =>
                {
                    s.alignSelf  = "auto";
                    s.width      = "auto";
                    s.height     = "auto";
                    s.flexShrink = "1";
                    s.overflow   = "hidden";
                    s.padding    = customPadding;
                }), component.Render());
                (component as dynamic).StackItem = item;
            }
            if (grow)
            {
                item.style.flexGrow = "1";
                item.style.height   = "10px";
            }

            Count++;
            item.style.transitionDelay = $"{0.05f * Count:n2}s";

            DomObserver.WhenMounted(item, () => item.classList.add("tss-ismounted"));

            return(item);
        }
Example #3
0
 private void HookCheck()
 {
     document.addEventListener("scroll", OnScroll, true);
     window.addEventListener("resize", OnScroll, true);
     DomObserver.WhenRemoved(InnerElement, UnHookCheck);
     //Trigger one time on first render, to force check if visible
     OnScroll(null);
 }
Example #4
0
 public void Reset()
 {
     DomObserver.WhenMounted(InnerElement, HookCheck);
     if (_maxCalls < 1) //will only reach 0 if it was single call
     {
         _maxCalls = 1;
     }
 }
Example #5
0
        public static T InvisibleScroll <T>(this T component) where T : IComponent
        {
            var element = component.Render();

            DomObserver.WhenMounted(element, () =>
            {
                var targetElement = Stack.GetItem(component);
                EnableInvisibleScroll(targetElement);
            });

            return(component);
        }
Example #6
0
        public static T Scroll <T>(this T component) where T : IComponent
        {
            var element = component.Render();

            DomObserver.WhenMounted(element, () =>
            {
                var targetElement             = Stack.GetItem(component);
                targetElement.style.overflowY = "auto";
            });

            return(component);
        }
Example #7
0
        public VisibilitySensor(Action <VisibilitySensor> onVisible, bool singleCall = true, IComponent message = null)
        {
            InnerElement = DIV();
            if (message is object)
            {
                InnerElement.appendChild(message.Render());
            }
            _onVisible = onVisible;
            _maxCalls  = singleCall ? 1 : int.MaxValue;

            DomObserver.WhenMounted(InnerElement, HookCheck);
        }
Example #8
0
 public static T WhenMounted <T>(this T component, Action callback) where T : IComponent
 {
     //No need to double check if already mounted here, as teh DomObserver already do it
     DomObserver.WhenMounted(component.Render(), callback);
     return(component);
 }
Example #9
0
 public static T WhenRemoved <T>(this T component, Action callback) where T : IComponent
 {
     DomObserver.WhenRemoved(component.Render(), callback);
     return(component);
 }
Example #10
0
 public dom.HTMLElement Render()
 {
     DomObserver.WhenMounted(_container, () => TriggerRefresh());
     return(_container);
 }