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

Grouping in SVG links #865

Open
zonky2 opened this issue Aug 9, 2018 · 2 comments
Open

Grouping in SVG links #865

zonky2 opened this issue Aug 9, 2018 · 2 comments

Comments

@zonky2
Copy link

zonky2 commented Aug 9, 2018

Hi,
I have several links in an SVG that should display HTML texts in the lightbox.

The display works, but I am not able to build in a grouping for one before <--> back.

The code looks something like this:

...
    <g>
    	<title>more...</title>
	    <a xlink:href="#text_1" class="colorbox_content xyz" data-cbox="lb1234">
	        <rect x="29.248" y="1311.749" fill="none" width="1014.101" height="282.029"/>
	    </a>
	</g>
    <g>
    	<title>more...</title>
	    <a xlink:href="#text_2" class="colorbox_content xyz" data-cbox="lb1234">
	        <rect x="29.248" y="1032.723" fill="none" width="774.078" height="279.026"/>
	    </a>
	</g>
...

any text blocks

<div class="colorbox_container" style="display:none;">
	<div id="text_1" style="margin: 20px;">
		<div>Text 1....</div>
	</div>
</div>
<div class="colorbox_container" style="display:none;">
	<div id="text_2" style="margin: 20px;">
		<div>Text 2....</div>
	</div>
</div>
...

and jQuery

<script>
$(document).on('click', '.colorbox_content', function(event){
    event.stopPropagation();
    event.preventDefault();
    var xhref = $(this).attr('xlink:href');
    var rel   = $(this).attr('data-cbox')
    $.colorbox({
    	maxWidth: '95%',
        maxHeight: '95%',
        opacity: '0.5',
    	inline: true,
    	rel: rel,
    	href: xhref,
    });
});
</script>
@jackmoore
Copy link
Owner

Hi, sorry about the late reply, I've been traveling. You should be able to use the SVG elements like you would any other DOM element. Does this work?

$('.colorbox_content').colorbox({
    	maxWidth: '95%',
        maxHeight: '95%',
        opacity: '0.5',
    	inline: true,
    	rel: function(){ return $(this).attr('xlink:href') },
    	href: function(){ return $(this).attr('xlink:href') },
});

@zonky2
Copy link
Author

zonky2 commented Aug 13, 2018

no, unfortunately this does not work 😞

I have only a svg element

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

2 participants