Skip to content

Commit

Permalink
Merge pull request #7 from Shprrr/fix-flickering
Browse files Browse the repository at this point in the history
Fix control flickering when changing Graph.

Fix #5
  • Loading branch information
KeRNeLith authored Mar 19, 2022
2 parents 21e04d1 + d0a4575 commit 5e3be16
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions src/GraphShape.Controls/Controls/GraphCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static void SetY(DependencyObject obj, double value)
[NotNull]
public static readonly RoutedEvent PositionChangedEvent = EventManager.RegisterRoutedEvent(
"PositionChanged", RoutingStrategy.Bubble, typeof(PositionChangedEventHandler), typeof(GraphCanvas));

/// <summary>
/// Adds a new <see cref="PositionChangedEvent"/> handler.
/// </summary>
Expand All @@ -141,7 +141,7 @@ public static void RemovePositionChangedHandler(DependencyObject d, RoutedEventH
uiElement.RemoveHandler(PositionChangedEvent, handler);
}
}

#endregion

#region Animation length
Expand All @@ -165,7 +165,7 @@ public TimeSpan AnimationLength
typeof(TimeSpan),
typeof(GraphCanvas),
new UIPropertyMetadata(new TimeSpan(0, 0, 0, 0, 500)));

#endregion

#region CreationAnimation
Expand Down Expand Up @@ -464,7 +464,10 @@ public virtual void Relayout()
/// <param name="control">The control which has been added.</param>
protected virtual void RunCreationTransition([NotNull] Control control)
{
CreationTransition?.Run(AnimationContext, control, AnimationLength);
if (CanAnimate)
{
CreationTransition?.Run(AnimationContext, control, AnimationLength);
}
}

/// <summary>
Expand Down Expand Up @@ -498,7 +501,7 @@ protected virtual void RunMoveAnimation([NotNull] Control control, double x, dou
/// </param>
protected virtual void RunDestructionTransition([NotNull] Control control, bool dontRemoveAfter)
{
if (DestructionTransition is null)
if (DestructionTransition is null || !CanAnimate)
{
if (!dontRemoveAfter)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ private static void OnLayoutModePropertyChanged(DependencyObject d, DependencyPr
// Check if we need to register or unregister watches on graph changes events
if (graphLayout.Graph is IMutableBidirectionalGraph<TVertex, TEdge> mutableGraph)
{
var oldMode = (LayoutMode)args.OldValue;
var oldMode = (LayoutMode)args.OldValue;
var newMode = (LayoutMode)args.NewValue;

bool wasCompoundMode = IsCompoundModeInternal(oldMode, graphLayout.Graph);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class FadeTransition : ITransition
/// <param name="startOpacity">Starting opacity value.</param>
/// <param name="endOpacity">Ending opacity value.</param>
public FadeTransition(double startOpacity, double endOpacity)
: this(startOpacity, endOpacity, 2)
: this(startOpacity, endOpacity, 1)
{
}

Expand Down

0 comments on commit 5e3be16

Please sign in to comment.