Как заставить Angular 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
    }
};

};

person user3456895    schedule 08.01.2016    source источник
comment
Не удалось решить проблему, поэтому вместо этого начал использовать angular ui-sortable. Работает как шарм.   -  person user3456895    schedule 03.02.2016


Ответы (1)


попробуй это.

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

})

person chitcharonko    schedule 15.04.2016
comment
чья это сфера? Это область видимости элемента $scope, $rootScope или HTML gridster? Расскажите пожалуйста... - person Ajay; 11.07.2016
comment
$scope не $rootScope. - person chitcharonko; 11.07.2016
comment
В моем случае $scope не работал, я использовал пользовательские параметры gridster для реализации соответствующей функции. Спасибо - person Ajay; 12.07.2016