Open photo with information without needing to click

Asked

Viewed 53 times

0

I’m a beginner in Jquery, and I’m trying to understand a code, and a template I downloaded for study, but I’m not understanding something, there’s a modal window that opens the text with image information.

The modal opens, and it has a button that I click to display the photo information,

below follows the excerpt of the code that displays and hides the information, it has some form that when opening the modal, the information already appear in the photo without needing to click the button modal__info ?

    $modalInfo = $('.modal__info'),


    function showProjectInfo($element) {
    var projectIsOpen = false,
        inProcess = false;

    //off/set handler on modal info btn



    $modalInfo
        .off('click')

        .one('click', function () {
            //find & clone project info to modal window
            $element.next().clone().appendTo($modalContent);
        })
        .on('click', function () {

            if (inProcess) return;

            inProcess = true;

            //already opened - close it
            if (projectIsOpen) {
                $modalContent
                    .find('.project-modal__inner')
                    .smoothAnimate({
                        opacity: [1, 0]
                    }, {
                        duration: 600,
                        complete: function () {
                            $modalContent
                                .find('.project-modal')
                                .smoothAnimate({

                                    height: ['100%', 0]
                                }, {
                                    duration: 600,
                                    easing: 'ease',
                                    complete: function () {
                                        projectIsOpen = false;
                                        inProcess = false;
                                    }
                                });
                        }
                    });
                return;
            }

            //not opened - open it
            //find project info in modal & animate it
            $modalContent
                .find('.project-modal')
                .css('display', 'block')
                .smoothAnimate({
                    height: [0, '100%']
                }, {
                    duration: 10,
                    easing: 'ease',
                    complete: function (elems) {
                        elems
                            .find('.project-modal__inner')
                            .smoothAnimate({
                                opacity: [0, 1]
                            }, {
                                duration: 10,
                                complete: function () {
                                    projectIsOpen = true;
                                    inProcess = false;
                                }
                            });
                    }
                });
        });
}
  • How are you opening this modal? Have you tried, after opening the modal, to click the button programmatically? Something like $('#idDoBotao').click()? Usually codes that open modal, have an event that runs after opening the modal, just by clicking the button there.

  • So, the button with the class ( .modal__info ) already opens the information, but I didn’t want to have to click, like, after I clicked the image passed 1 second and the information appeared, but I don’t know how to do this!

  • Then copy the code q put the image information and put inside a setTimout to run 1 second after opening the modal. The idea of clicking the button via code is to reuse the code without having to copy.

No answers

Browser other questions tagged

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