Permalink
Browse files

Read module re-initialize on window resize.

  • Loading branch information...
1 parent 301bdb6 commit 6a728c7996e0729365048b79811c6eeb66ae51b0 @a-fung committed Oct 12, 2012
Showing with 29 additions and 0 deletions.
  1. +29 −0 source/scriptsharp/Module/ReadModule.cs
@@ -137,6 +137,8 @@ private int SliderOffset
private int sliderTouchInitialOffset;
private int sliderTouchInitialXPosition;
+ private SelfClearingTimeout resizeTimeout = new SelfClearingTimeout();
+
private ReadModule()
: base("client", "read-module")
{
@@ -167,6 +169,7 @@ private ReadModule()
jQuery.Select(".arrow-btn").Click(ArrowButtonClicked);
jQuery.Document.Keyup(OnKeyUp);
jQuery.Document.Bind("mousewheel DOMMouseScroll", MouseWheelHandler);
+ jQuery.Window.Resize(OnResize);
}
protected override void OnShow()
@@ -846,5 +849,31 @@ private void MouseWheelHandler(jQueryEvent e)
}
}
}
+
+ private void OnResize(jQueryEvent e)
+ {
+ if (attachedObject.Is(":visible"))
+ {
+ resizeTimeout.Start(
+ delegate
+ {
+ if (attachedObject.Is(":visible"))
+ {
+ if (Settings.DisplayType == 0 && attachedObject.GetHeight() == jQuery.Window.GetHeight())
+ {
+ return;
+ }
+
+ if (Settings.DisplayType == 1 && attachedObject.GetHeight() == jQuery.Window.GetHeight() && oldWidth == jQuery.Window.GetWidth())
+ {
+ return;
+ }
+
+ InitializeRead();
+ }
+ },
+ 1200);
+ }
+ }
}
}

0 comments on commit 6a728c7

Please sign in to comment.