Beispiel #1
0
 public async ValueTask <decimal> oRequestAnimationFrame(FrameRequestCallback callback)
 {
     return(await EventHorizonBlazorInterop.Func <decimal>(
                new object[]
     {
         new string[] { this.___guid, "oRequestAnimationFrame" }, callback
     }
                ));
 }
 public decimal mozRequestAnimationFrame(FrameRequestCallback callback)
 {
     return(EventHorizonBlazorInterop.Func <decimal>(
                new object[]
     {
         new string[] { this.___guid, "mozRequestAnimationFrame" }, callback
     }
                ));
 }
Beispiel #3
0
        public static void MakeScrollableOnHover(HTMLElement element, int initialDelay = 1000, double pixelsPerSecond = 100)
        {
            double progress = 0;
            bool   stop     = false;
            double initial  = 0;
            double maxDelta = 0;
            double t0       = -1;
            double ratio    = 1;
            FrameRequestCallback animateElement = null;

            var target = ((HTMLElement)element.firstElementChild);

            animateElement = (t) =>
            {
                if (t0 < 0)
                {
                    t0    = t;
                    ratio = (pixelsPerSecond) / 1000;
                }
                progress = (t - t0) * ratio;
                if (progress > maxDelta || stop)
                {
                    if (stop)
                    {
                        target.style.marginLeft = "";
                    }
                    else
                    {
                        target.style.marginLeft = "-" + maxDelta + "px";
                    }
                }
                else
                {
                    target.style.marginLeft = "-" + (progress) + "px";
                    window.requestAnimationFrame(animateElement);
                }
            };

            element.onmouseenter = (e) =>
            {
                stop     = false;
                progress = 0;
                t0       = -1;
                maxDelta = -((DOMRect)element.getBoundingClientRect()).width;

                foreach (var c in element.children)
                {
                    maxDelta += ((DOMRect)c.getBoundingClientRect()).width;
                }

                if (maxDelta > 0)
                {
                    initial = window.setTimeout((t) =>
                    {
                        window.requestAnimationFrame(animateElement);
                    }, initialDelay);
                }
            };

            element.onmouseleave = (e) =>
            {
                stop = true;
                window.clearTimeout(initial);
                target.style.marginLeft = "";
            };
        }
Beispiel #4
0
 /// <summary>
 /// </summary>
 /// <param name="func">
 /// </param>
 public static void QueueNewFrame(FrameRequestCallback func)
 {
     Engine.window.requestAnimationFrame(func);
 }
Beispiel #5
0
 public static int RequestAnimationFrame(FrameRequestCallback callback)
 {
     return(0);
 }
Beispiel #6
0
 public static int RequestAnimationFrame(FrameRequestCallback callback)
 {
     return 0;
 }