Integrating fancyBox3

(Reza) #1

Hi I want to integrate fancyBox3 into my document. Here is their quick start suggestions:

<!-- 1. Add latest jQuery and fancyBox files -->

<script src="//"></script>

<link rel="stylesheet" href="" />
<script src=""></script>

<!-- 2. Create links -->

<a data-fancybox="gallery" href="big_1.jpg"><img src="small_1.jpg"></a>
<a data-fancybox="gallery" href="big_2.jpg"><img src="small_2.jpg"></a>

How can I get this integrated into Hype


You will only be able to use HTML inside a Hype element as fancyBox relies on “data” attributes which Hype does not use in it’s setup. Open the innerHTML of any element and you can paste the demo code in there. (21.4 KB)

(Mark Hunte) #3

Although you can add the attributes using JS.

Basic idea

 var fancyImage1 = hypeDocument.getElementById('fancyImage1')
	 hypeDocument.setElementProperty(fancyImage1, 'background-image', '' )
  	fancyImage1.setAttribute("data-caption", fancyImage1.title);
	fancyImage1.setAttribute("href" , "");

fancyBox4 (247.6 KB)


True but I didn’t want to add more complexity to a situation that, i may have wrongly assumed was a user who wouldn’t be able to grasp this. Plus in my mind it would detract away from the ease of using this third party library. There may also be some additional things that the library does and that’s to organise the pics into a gallery of sorts and also you wouldn’t be able to grab the example code in this way but this is a valid point. You can manipulate and add the attributes using JS. :slight_smile:

P.S @MarkHunte fancyBox3 is the actual title of the library. I don’t believe they have a 4 version … i may be wrong :stuck_out_tongue:

(Mark Hunte) #5

Agree, In most cases using the innerHTML is more convenient, although a quick look I see there are extensive/complex API for fancy box.

Yer, That was my main point really. :smile:

hah 4, I was just pushing the example version along doh…

(Reza) #6

Thanks for helping out.
I have been exploring DBear’s suggestion and infect I want to open a Vimeo video with this library.
I added the scripts in the header and added a button with the link to the vimeo video and it all works well.
However if I go back to edit the button, as soon as I tap on it to access the editor for the button. the script runs and the video is displayed in the app. I can not find a way to go back or close the overlay. Also now the file would not even open.

I also want to add a local image and get that to open the video. I know in DBear’s example he has the tag on a linked image, but if it is local, the source of the image is not available to add a link to it. How would I get around this, or would I need to post my image somewhere else and use it in the source which could be possible.

Also now something has gone wrong with the file that I cant even post it for you to see.
If there are alternative libraries that play better with Hype please let me know.

(Reza) #7

I ended up adopting Mark Hunte suggestion. even though it is a little more complicated but I felt it was safer. Here is an example with 2 buttons, one opening a movie and the other opening an iframe.
PS I restated my computer and I could open the old file, but some information has been lost. (259.4 KB)