你如何触发角砌筑重装? [英] How do you trigger a reload in angular-masonry?

查看:148
本文介绍了你如何触发角砌筑重装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我砌体用href=\"https://github.com/passy/angular-masonry\" rel=\"nofollow\">角砌筑指令的

I got Masonry to work in my AngularJS app using the angular-masonry directive but I want to be able to call a function or method in my controller that will trigger a reload of items in the container. I see in the source code (lines 101-104) there is a reload method but I'm not sure how to invoke that. Any ideas?

谢谢!

推荐答案

在情况下,它使用的人在未来,帕西手表称为masonry.reload的事件。

In case it's of use to someone in the future, Passy watches for an event called masonry.reload.

所以,你可以发出此事件,并帕西应该叫'布局'砖石元素,例如上呼叫

So, you can issue this event and Passy should call 'layout' on the masonry element, e.g. call

$rootScope.$broadcast('masonry.reload');

在我的情况,我有JavaScript的装饰我的砖一些第三方的,所以我需要重新绘制的做了。对于原因(我没能弄清楚为什么),我需要换事件播出超时,我觉得帕西调度是吃了该事件,并没有重新粉刷。例如。我所做的:

In my case, I had some third-party javascript decorating my bricks, so I needed to repaint after that was done. For reason (I was not able to figure out why), I needed to wrap the event broadcast in a timeout, I think the Passy scheduler was eating up the event and not repainting. E.g. I did:

$timeout(function () {
   $rootScope.$broadcast('masonry.reload');
   }, 5000);

这样,您就不必直接修改帕西。​​

This way you don't have to modify Passy directly.

这篇关于你如何触发角砌筑重装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆