Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open Popup (Image Gallery) from Link #113

Closed
ghost opened this issue Jun 12, 2013 · 5 comments
Closed

Open Popup (Image Gallery) from Link #113

ghost opened this issue Jun 12, 2013 · 5 comments

Comments

@ghost
Copy link

ghost commented Jun 12, 2013

First: Thank you very much for this great peace of code. One question left. Are there ways to open a gallery from a single Textlink?

Sample:

<div class="gallery-link">
<a href="#">Open the Gallery</a>
</div>

<div class="gallery">
<img src="" />
<img src="" />
<img src="" />
.
.
.
</div>

Thank you

@dimsemenov
Copy link
Owner

Depends on how you initialized the gallery, but basically:

$('.gallery').magnificPopup('open');

To open at specific index:

$('.gallery').magnificPopup('open', 3);

@ghost
Copy link
Author

ghost commented Jun 19, 2013

Thank you very much.

@ghost ghost closed this as completed Jun 19, 2013
@ryanjbonnell
Copy link

You can view a working example on CodePen.

HTML:

<div class="gallery-link">
    <a href="#">Open Gallery</a>
</div>

<div class="gallery">
    <a href="http://farm9.staticflickr.com/8242/8558295633_f34a55c1c6_b.jpg"></a>
    ...
    <a href="http://farm9.staticflickr.com/8225/8558295635_b1c5ce2794_b.jpg"></a>
</div>

jQuery:

// Bind Click Handler to Link, then Open Gallery
$('.gallery-link').on('click', function () {
    $(this).next().magnificPopup('open');
});

// Initialize Magnific Popup Gallery + Options
$('.gallery').each(function () {
    $(this).magnificPopup({
        delegate: 'a',
        gallery: {
            enabled: true
        },
        type: 'image'
    });
});

@pierrocknroll
Copy link

Hi, and thanks for this great solution.

Is it possible to have animations with this kind of gallery ? I can't get http://codepen.io/dimsemenov/pen/GAIkt to work with it.

@ghost
Copy link
Author

ghost commented Jun 5, 2015

Thank you for the great piece of code.

Have an issue with

$(document).ready(function () {
$('.gallery-link').click(function () {
jQuery(this).next().magnificPopup('open');
});
$('.gallery').each(function () {
jQuery(this).magnificPopup({
delegate: 'a',
type: 'image',
gallery: {
enabled: true,
navigateByImgClick: true
},
fixedContentPos: false
});
});
});

On .magnificPopup('open') Error: Unable to get property 'items' of undefined or null reference
Line: 930 in jquery.magnific-popup.js (v1.0.0 - 2015-01-03 )

Please help.

Thank you

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants