【问题标题】:How to make Angular Gridster dynamically change column length on resizing window如何使 Angular Gridster 在调整窗口大小时动态更改列长度
【发布时间】:2016-01-08 20:37:47
【问题描述】:

我遇到了这个问题,当我调整浏览器窗口的大小时,网格中的所有元素都变得杂乱无章。我已将链接添加到调整窗口大小之前和之后的外观。

调整大小后

调整大小之前

gridster 选项如下:

$scope.gridsterOpts = {
    columns: 10, // the width of the grid, in columns
    pushing: false, // whether to push other items out of the way on move or resize
    floating: true, // whether to automatically float items up so they stack (you can temporarily disable if you are adding unsorted items with ng-repeat)
    swapping: true, // whether or not to have items of the same size switch places instead of pushing down if they are the same size
    width: 'auto', // can be an integer or 'auto'. 'auto' scales gridster to be the full width of its containing element
    colWidth: 'auto', // can be an integer or 'auto'.  'auto' uses the pixel width of the element divided by 'columns'
    rowHeight: 'match', // can be an integer or 'match'.  Match uses the colWidth, giving you square widgets.
    margins: [30, 30], // the pixel distance between each widget
    outerMargin: true, // whether margins apply to outer edges of the grid
    isMobile: false, // stacks the grid items if true
    mobileBreakPoint: 600, // if the screen is not wider that this, remove the grid layout and stack the items
    mobileModeEnabled: true, // whether or not to toggle mobile mode when screen width is less than mobileBreakPoint
    minColumns: 1, // the minimum columns the grid must have
    minRows: 1, // the minimum height of the grid, in rows
    maxRows: 100,
    defaultSizeX: 2, // the default width of a gridster item, if not specifed
    defaultSizeY: 1, // the default height of a gridster item, if not specified
    minSizeX: 1, // minimum column width of an item
    maxSizeX: 1, // maximum column width of an item
    minSizeY: 1, // minumum row height of an item
    maxSizeY: 1, // maximum row height of an item
    resizable: {
        enabled: false,
        handles: ['n', 'e', 's', 'w', 'ne', 'se', 'sw', 'nw'],
        start: function(event, $element, widget) {}, // optional callback fired when resize is started,
        resize: function(event, $element, widget) {}, // optional callback fired when item is resized,
        stop: function(event, $element, widget) {} // optional callback fired when item is finished resizing
    },
    draggable: {
        enabled: true, // whether dragging items is supported
        handle: '.my-class', // optional selector for resize handle
        start: function(event, $element, widget) {}, // optional callback fired when drag is started,
        drag: function(event, $element, widget) {}, // optional callback fired when item is moved,
        stop: function(event, $element, widget) {} // optional callback fired when item is finished dragging
    }
};

};

【问题讨论】:

  • 无法解决问题,因此开始使用 angular ui-sortable 代替。像魅力一样工作。

标签: angularjs overlap gridster responsiveness


【解决方案1】:

试试这个。

scope.$on('gridster-resized', function(sizes, gridster) {
// sizes[0] = width
// sizes[1] = height
// gridster.

})

【讨论】:

  • 这是谁的范围?是 $scope、$rootScope 还是 HTML gridster 元素范围?请告诉...
  • $scope 不是 $rootScope。
  • $scope 在我的情况下不起作用,我使用自定义 gridster 选项来实现相应的功能。谢谢
猜你喜欢
  • 2011-02-15
  • 1970-01-01
  • 2021-04-06
  • 2013-09-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-03
相关资源
最近更新 更多