Пример #1
0
        /// <summary>Halts this instance.</summary>
        public void Stop(bool runEvent)
        {
            if (!Started)
            {
                return;
            }

            if (runEvent)
            {
                AnimationEvent ae = new AnimationEvent("animationend");
                ae.animationName = RawAnimation.Name;
                ae.elapsedTime   = Duration * RepeatCount;
                ae.SetTrusted(false);
                Style.Element.dispatchEvent(ae);
            }

            // Clear host:
            if (Style.AnimationInstance == this)
            {
                Style.AnimationInstance = null;
            }

            Started = false;

            if (Animation != null)
            {
                // Halt the animation (never call OnDone here):
                Animation.Stop(false);
                Animation = null;
            }
        }
Пример #2
0
        /// <summary>Starts this instance.</summary>
        public void Start()
        {
            if (Paused || Started || RawAnimation == null)
            {
                // Block start request.
                return;
            }

            Started = true;

            // Start running backwards?
            Backwards = (((int)Direction & 1) == 1);

            // Set the current frame:
            if (Backwards)
            {
                CurrentFrame = RawAnimation.FrameCount - 1;
            }
            else
            {
                CurrentFrame = 0;
            }

            AnimationEvent ae = new AnimationEvent("animationstart");

            ae.animationName = RawAnimation.Name;
            ae.SetTrusted(false);
            Style.Element.dispatchEvent(ae);

            Run();
        }
Пример #3
0
        /// <summary>Called when a cycle is completed.</summary>
        private void CompletedCycle()
        {
            // Can we repeat? -1 is infinite.
            if (RepeatCount != -1)
            {
                RepeatCount--;

                // Got to stop?
                if (RepeatCount == 0)
                {
                    Stop(true);
                    return;
                }
            }

            AnimationEvent ae = new AnimationEvent("animationiteration");

            ae.animationName = RawAnimation.Name;
            ae.elapsedTime   = Duration * RepeatCount;
            ae.SetTrusted(false);
            Style.Element.dispatchEvent(ae);

            // If alternate, flip the direction:
            if (((int)Direction & 2) == 2)
            {
                Backwards = !Backwards;
            }
            else
            {
                // Start running backwards?
                Backwards = (((int)Direction & 1) == 1);
            }

            // Set the current frame:
            if (Backwards)
            {
                CurrentFrame = RawAnimation.FrameCount - 1;
            }
            else
            {
                CurrentFrame = 0;
            }

            Run();
        }