试图让Packery.js使用我正在使用的angularjs应用程序。
因为某种原因,他们似乎在一起玩得不太好。我想它可能会解决与isInitLayout错误设置,但是,仍然没有爱。
这里是我的(引导3) HTML:
<div class="row" class="js-packery"
data-packery-options='{ "itemSelector": ".packery-item",
"gutter": 10,
"columnWidth": 60,
"isInitLayout": false }'>
<artifact class="packery-item" ng-repeat="(index, thing) in data | limitObjectTo:4" thing="thing"></artifact>
</div>我开始怀疑这是不是因为我使用的神器指令..。
发布于 2014-01-22 16:20:20
如前所述,您必须制定一个指令来处理Packery的使用。
这个指令使Packery在我正在处理的项目中与AngularJS一起工作。
工作小提琴:http://jsfiddle.net/8P6mf/2/
HTML:
<div class="wrapper">
<div ng-repeat="item in test" danny-packery>
{{item.name}}
</div>
</div>JavaScript:
var dannyPackery = app.directive('dannyPackery', ['$rootScope', function($rootScope) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
console.log('Running dannyPackery linking function!');
if($rootScope.packery === undefined || $rootScope.packery === null){
console.log('making packery!');
$rootScope.packery = new Packery(element[0].parentElement, {columnWidth: '.item'});
$rootScope.packery.bindResize();
$rootScope.packery.appended(element[0]);
$rootScope.packery.items.splice(1,1); // hack to fix a bug where the first element was added twice in two different positions
}
else{
$rootScope.packery.appended(element[0]);
}
$rootScope.packery.layout();
}
};
}]);发布于 2013-10-21 15:15:15
您发现的任何JS库都不会简单地使用角。causes会编译DOM,这会导致其他库失去上下文。您必须编写自定义指令。
我发现了一个现有的砌体指令:https://github.com/passy/angular-masonry和packery非常类似于砖石,所以我相信您可以将它修改到容器中。
https://stackoverflow.com/questions/19498174
复制相似问题