AngularJS - call wookmark layout without using $ timout

I am currently involved in the task of creating pinterest, for example, thumbnails using the wookmark and angularjs plugin. On which I can display thumbnails using $ timeout 10 seconds, because the server takes time to respond. I wanted to call the layout after the data was fully loaded. I tried with a promise, but no luck.

Is there a way to invoke a Wookmark layout without using $ timeout?

my code supports:

myApp.controller("MyCtrl", ['$scope', '$timeout', 'eventData', function($scope, $timeout, eventData) { function init() { $scope.publicstreams = []; $scope.publicstreams = eventData.getEvent(0); $timeout(initWookmark, 10000); } function initWookmark() { var options = { autoResize: true, // This will auto-update the layout when the browser window is resized. container: $('#tiles'), // Optional, used for some extra CSS styling offset: 5, // Optional, the distance between grid items flexibleWidth: 310 // Optional, the maximum width of a grid item }; var handler = $('#tiles li'); $('#tiles').imagesLoaded(function() { // Prepare layout options. // Get a reference to your grid items. // Call the layout function. handler.wookmark(options); }); handler.wookmark(options); } init(); }]); 

Any help would be greatly appreciated!

+4
source share
1 answer

Thank god!

I finally figured it out. I set the delay to 0 in $ timeout and it worked.

How?

$ timeout is actually executed after the completion of the DOM rendering in the browser. Thus, even a 0 millisecond delay works.

+2
source

Source: https://habr.com/ru/post/1493149/


All Articles