[view] add back method to frame switcher
This commit is contained in:
@@ -18,6 +18,7 @@ class ButtonView extends LabelView {
|
||||
public var disabled(default, set):Bool;
|
||||
public var state(get, null):ButtonState;
|
||||
public var onPress(default, null):Signal<ButtonView>;
|
||||
public var propagation(default, default):Bool;
|
||||
|
||||
private var overed:Bool;
|
||||
private var downed:Bool;
|
||||
@@ -26,6 +27,7 @@ class ButtonView extends LabelView {
|
||||
super();
|
||||
skin = new ButtonColorSkin();
|
||||
style = "button";
|
||||
propagation = true;
|
||||
overed = false;
|
||||
downed = false;
|
||||
state = ButtonState.UP;
|
||||
@@ -47,7 +49,7 @@ class ButtonView extends LabelView {
|
||||
|
||||
private function onMouseClick(event:MouseEvent):Void {
|
||||
#if js if (downed) { #end
|
||||
//event.stopImmediatePropagation();
|
||||
if (!propagation) event.stopImmediatePropagation();
|
||||
if (!disabled) onPress.emit(this);
|
||||
#if js } #end
|
||||
}
|
||||
|
||||
@@ -17,11 +17,13 @@ class FrameSwitcher extends GroupView {
|
||||
public var animateFactory(default, default):Class<IAnimate>;
|
||||
|
||||
private var animate:IAnimate;
|
||||
private var history:Array<{id:String, data:Dynamic}>;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
factory = new Map();
|
||||
frames = new Map();
|
||||
history = [];
|
||||
current = null;
|
||||
}
|
||||
|
||||
@@ -65,16 +67,23 @@ class FrameSwitcher extends GroupView {
|
||||
}
|
||||
animate = buildAnimate(current);
|
||||
if (animate != null && prev != null) {
|
||||
animate.start(function(_) {
|
||||
removePrev(prev);
|
||||
});
|
||||
animate.start(function(_) removePrev(prev));
|
||||
} else {
|
||||
removePrev(prev);
|
||||
}
|
||||
history.push({id:current.frameId, data:data});
|
||||
onSwitch.emit(current);
|
||||
return cast current;
|
||||
}
|
||||
|
||||
public function back():Void {
|
||||
if (history.length > 1) {
|
||||
history.pop();
|
||||
var item = history.pop();
|
||||
change(item.id, item.data);
|
||||
}
|
||||
}
|
||||
|
||||
private function removePrev(prev:Null<FrameView<Dynamic>>):Void {
|
||||
if (prev != null) {
|
||||
prev.onHide();
|
||||
|
||||
Reference in New Issue
Block a user