diff --git a/examples/dev.html b/examples/dev.html
index 3da8b21c9..092b90c16 100644
--- a/examples/dev.html
+++ b/examples/dev.html
@@ -12,7 +12,7 @@
var Model = BI.inherit(Fix.Model, {
state: function () {
return {
- count: 0
+ columnSize: [200, "fill"]
};
}
});
@@ -20,6 +20,10 @@
BI.model("demo.model", Model);
var Widget = BI.inherit(BI.Widget, {
+ props: {
+ height: 200,
+ width: 600
+ },
_store: function () {
return BI.Models.getModel("demo.model");
},
@@ -27,15 +31,27 @@
var store = BI.useStore();
return function () {
return {
- type: "bi.vertical",
+ type: "bi.htape",
+ columnSize: function () {
+ return store.model.columnSize;
+ },
items: [{
- type: "bi.button",
- effect: function () {
- this.setText(store.model.count)
- },
- handler: function () {
- store.model.count++;
+ type: "bi.label",
+ css: {
+ background: "#eee"
}
+ }, {
+ type: "bi.center_adapt",
+ css: {
+ background: "#e0e0e0"
+ },
+ items: [{
+ type: "bi.button",
+ text: "点击",
+ handler: function () {
+ store.model.columnSize = [300, "fill"]
+ }
+ }]
}]
};
};
diff --git a/examples/resize.html b/examples/resize.html
new file mode 100644
index 000000000..5bd99a35d
--- /dev/null
+++ b/examples/resize.html
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/core/4.widget.js b/src/core/4.widget.js
index 627128265..29ea02322 100644
--- a/src/core/4.widget.js
+++ b/src/core/4.widget.js
@@ -163,7 +163,7 @@
}
if (o.cls) {
if (BI.isFunction(o.cls)) {
- var cls = this.__watch(o.cls, function (newValue) {
+ var cls = this.__watch(o.cls, function (context, newValue) {
self.element.removeClass(cls).addClass(cls = newValue);
});
this.element.addClass(cls);
@@ -182,7 +182,7 @@
}
if (o.css) {
if (BI.isFunction(o.css)) {
- var css = this.__watch(o.css, function (newValue) {
+ var css = this.__watch(o.css, function (context, newValue) {
for (var k in css) {
if (!newValue[k]) {
newValue[k] = "";
@@ -205,8 +205,8 @@
this._watchers = this._watchers || [];
var watcher = new Fix.Watcher(null, function () {
return getter.call(self, self);
- }, (handler && function () {
- handler.call(self, self);
+ }, (handler && function (v) {
+ handler.call(self, self, v);
}) || BI.emptyFn, options);
this._watchers.push(watcher);
return watcher.value;
diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js
index 1f92a98d1..8093ae5fc 100644
--- a/src/core/wrapper/layout.js
+++ b/src/core/wrapper/layout.js
@@ -19,8 +19,27 @@ BI.Layout = BI.inherit(BI.Widget, {
},
render: function () {
+ var self = this, o = this.options;
this._init4Margin();
this._init4Scroll();
+ if (BI.isFunction(o.columnSize)) {
+ var columnSizeFn = o.columnSize;
+ o.columnSize = this.__watch(columnSizeFn, function (context, newValue) {
+ o.columnSize = newValue;
+ self.resize();
+ }, {
+ deep: true
+ });
+ }
+ if (BI.isFunction(o.rowSize)) {
+ var rowSizeFn = o.rowSize;
+ o.rowSize = this.__watch(rowSizeFn, function (context, newValue) {
+ o.rowSize = newValue;
+ self.resize();
+ }, {
+ deep: true
+ });
+ }
},
_init4Margin: function () {