angular-masonry icon indicating copy to clipboard operation
angular-masonry copied to clipboard

Load Images and rearranging issue

Open Bahnduame opened this issue 9 years ago • 5 comments

When load-images is set to true on my masonry div, my images load properly, but upon rearranging (filtering through angular) the bricks will have large gaps between each other. When load-images is set to false, bricks will overlap on initial load, but upon any kind of rearranging (window resizing or filtering) the bricks will adjust to properly space.

I have tried to initially set load-images to true and then make a timeout to set it to false a few hundred milliseconds later. This does not seem to work.

load-images-set-to-false

image-load-set-to-true

Bahnduame avatar Oct 15 '14 06:10 Bahnduame

Did you try to run reload on the controller? It looks to me like the layout method of masonry needs to be called after the filtering (at least I had similar issues with the non angular version after the masonry items changed)

DanielMSchmidt avatar Dec 07 '14 17:12 DanielMSchmidt

So is there a way to retrigger the masonry layout function through this directive? I'm getting the same issue as @Bahnduame...

CoenWarmer avatar May 30 '15 19:05 CoenWarmer

@CoenWarmer check youanswer's comment here: https://github.com/passy/angular-masonry/issues/4. It worked fine for me (on most devices, at least).

rbosneag avatar Jun 18 '15 11:06 rbosneag

Can you check if you put the following code inside the directive 'masonryBrick' if it helps you?

scope.$watch(function () {
    return element.height();
},
function (newValue, oldValue) {
    if (newValue != oldValue) {
        ctrl.scheduleMasonryOnce('reloadItems');
        ctrl.scheduleMasonryOnce('layout');
    }
});

JoseCMRocha avatar Nov 18 '15 09:11 JoseCMRocha

i have exact the same problem. I am not sure that i implemented youranswer's solution right. I wrote the following code inside my Controller

$scope.$watch('filterText', function() { $timeout(function () { $rootScope.$broadcast('masonry.reload'); }, 200); });

And seems to work but am not satisfied... Do you have another recommendation ???

donMichaelL avatar Apr 19 '16 14:04 donMichaelL