Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable jQuery Masonry

I'm trying to disable jQuery masonry for certain states of a page on my site but can't seem to find a way to do it. Do you know how I could do this? Thanks.

like image 909
Tomm Armstrong Avatar asked Feb 22 '13 06:02

Tomm Armstrong


People also ask

How to disable any control with jQuery?

To disable any control with jQuery pass true as the second argument to the .prop () method. There is an input control and a button. On the button click event I will disable the input control. Here I have a disabled input control which I will enable on the button click. Sometimes you want to keep the submit button of a form disabled.

How to get the masonry instance from a jQuery object?

Get the Masonry instance from a jQuery object. Masonry instances are useful to access Masonry properties. Get the Masonry instance via its element. Masonry.data () is useful for getting the Masonry instance in JavaScript, after it has been initalized in HTML.

How do I use itemselector in masonry?

Masonry will lay out item elements around stamped elements. Set itemSelector so that stamps do not get used as layout items. Un-stamps elements in the layout, so that Masonry will no longer layout item elements around them. See demo above. Adds and lays out newly appended item elements to the end of the layout.

How can I speed up the animation on masonry?

The most obvious is to use jQuery, which you can turn on by calling isAnimated: true when calling on Masonry. This does the job, but jQuery animation relies on DOM manipulation and having several large bricks can slow down the animation performance and make the experience feel sluggish.


2 Answers

Here is the list of methods http://desandro.github.io/masonry/docs/methods.html#content

Assuming your Masonry container ID is #masonry

$('#masonry').masonry( 'destroy' );
like image 97
Luke Avatar answered Sep 28 '22 06:09

Luke


I used @kaverzniy's answer but wrapped it in

var container = $('#container'); // or whatever your container is
if(container.masonry()) {
    $('#masonry').masonry( 'destroy' );
}

to avoid calling methods on masonry prior to initialization (in case it hadn't been initialized yet).

like image 43
Little Package Avatar answered Sep 28 '22 08:09

Little Package