基于Angularjs with Packery.js提供的解决方案,我能够在Angularjs中使用packery.js库
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();
}
};
}]);如何将可拖动选项添加到上述代码中?http://packery.metafizzy.co/draggable.html中提供了可拖动选项的jquery代码。如有任何意见,欢迎光临
发布于 2017-01-29 06:31:33
我最终使用了this库,它工作得很好。
https://stackoverflow.com/questions/41844835
复制相似问题