【问题标题】:Angularjs with packery.js draggableAngularjs 与 packery.js 可拖动
【发布时间】:2017-01-25 06:26:29
【问题描述】:

根据Angularjs with Packery.js 中提供的解决方案,我能够让 packery.js 库在 Angularjs 中工作

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();
        }
    };
}]);

如何将可拖动选项添加到上述代码中?此处提供了可拖动选项的 jquery 代码http://packery.metafizzy.co/draggable.html。任何意见表示赞赏

【问题讨论】:

    标签: javascript jquery html angularjs


    【解决方案1】:

    我最终使用了this 库,它运行良好。

    【讨论】:

      猜你喜欢
      • 2013-10-30
      • 1970-01-01
      • 2017-05-22
      • 1970-01-01
      • 2016-04-16
      • 2014-10-26
      • 2012-12-27
      • 2014-05-24
      • 2013-11-26
      相关资源
      最近更新 更多