Created
December 20, 2011 16:19
-
-
Save mikecann/1502136 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package content.views.main; | |
import base.BaseView; | |
import content.views.common.DivView; | |
import content.views.foreground.ForegroundView; | |
import js.JQuery; | |
import js.Lib; | |
import js.Dom; | |
import hsl.haxe.Signaler; | |
import hsl.haxe.DirectSignaler; | |
/** | |
* ... | |
* @author | |
*/ | |
class MainView extends BaseView | |
{ | |
public var bg : DivView; | |
public var fg : ForegroundView; | |
public var closed : Signaler<Void>; | |
public function new() | |
{ | |
super(Lib.document.createElement('div')); | |
closed = new DirectSignaler(this); | |
// Add children | |
add(bg = new DivView('ptt_background')); | |
add(fg = new ForegroundView()); | |
// Listen for some events | |
new JQuery(cast Lib.window).resize(onWindowResize); | |
// Position | |
centreForeground(); | |
} | |
public function open() : Void | |
{ | |
new JQuery(bg.element).css({opacity:0}).fadeTo(250, 0.8); | |
new JQuery(fg.element).css( { left: -600 } ).animate( { left: Lib.window.innerWidth/2-300, easing:'easein' }, 250); | |
} | |
public function close() : Void | |
{ | |
new JQuery(bg.element).css({opacity:0.8}).fadeTo(250, 0, onCloseComplete); | |
new JQuery(fg.element).animate( { left: Lib.window.innerWidth, easing:'easein' }, 250); | |
} | |
private function onCloseComplete():Void | |
{ | |
closed.dispatch(); | |
} | |
private function centreForeground():Void | |
{ | |
var ww = Lib.window.innerWidth; | |
var wh = Lib.window.innerHeight; | |
var fgw = new JQuery(fg.element).width(); | |
var fgh = new JQuery(fg.element).height(); | |
fg.element.style.left = ((ww / 2) - (fgw / 2)) + 'px'; | |
fg.element.style.top = ((wh / 2) - (fgh / 2)) + 'px'; | |
} | |
private function onWindowResize(e):Void | |
{ | |
centreForeground(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment