Is it possible to configure a Jquery Effect?

Asked

Viewed 38 times

3

It is possible to change the options on Toggle Explode? For example: it has nine divisions by default, is it possible to modify the number of parts in which it explodes and the size of these parts? I was also wondering if JQuery allows you to change the size of the explosion of this effect, because in my case the div page exit.

1 answer

4


You can choose the number of parts through the option pieces:

$(elemento).toggle("explode", {
    pieces: 25
});

The number of pieces need not be square, but second the source code it will round the square root of that number to choose the number of rows and columns (i.e. the pieces will be squares, with the same number of rows and columns - no rectangular pieces).

There is no option to customize the size of the explosion. Also according to the sources, the displacement is proportional to the size of the piece (Edit: in fact it is more or less the same every time; except for a small rounding, it will take up twice the space of the original element), and it always explodes out of its original space (unless the number of pieces is 4, in which case the bottom right part does not move).

Example in jsFiddle. If you really need the size of the explosion to be smaller, I suggest you define your own effect, using the explode code as a reference. It is sufficient that in the css and/or in the animate (depending on whether you are showing or hiding) you multiply the final displacement by a factor of your choice:

var meuFator = 0.2;

...

left: offset.left + j*(width/cells) +
      (o.options.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells)*meuFator : 0),
  • I have researched in several places and realized that in my case, it is not possible to accomplish what I wish, but its correct answer well explanatory!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.