【发布时间】:2014-07-28 19:14:51
【问题描述】:
在使用敲除更改模板时,有没有办法在“页面”更改之间设置过渡动画?我正在寻找类似于Knockback-Navigators 的东西。我想不出办法做到这一点?有没有可以让这更容易的包?这是一个JSFiddle,与我的项目使用的绑定类型相同。还有我的 javascript 示例:
var View = function (title, templateName, data) {
var self = this;
this.title = title;
this.templateName = templateName;
this.data = data;
this.url = ko.observable('#' + templateName);
};
var test1View = {
test: ko.observable("TEST1")
};
var test2View = {
test: ko.observable("TEST2")
};
var viewModel = {
views: ko.observableArray([
new View("Test 1", "test1", test1View),
new View("Test 2", "test2", test2View)]),
selectedView: ko.observable(),
}
//Apply knockout bindings
ko.applyBindings(viewModel);
//Set up sammy url routes
Sammy(function () {
//Handles only groups basically
this.get('#:view', function () {
var viewName = this.params.view;
var tempViewObj = ko.utils.arrayFirst(viewModel.views(), function (item) {
return item.templateName === viewName;
});
//set selectedView
viewModel.selectedView(tempViewObj);
});
}).run('#test1');
【问题讨论】:
标签: javascript jquery animation knockout.js sammy.js