30.07.2013 Views

Swipe Gallery. HTML5 Component..2.. swipegallery.css ... - Google

Swipe Gallery. HTML5 Component..2.. swipegallery.css ... - Google

Swipe Gallery. HTML5 Component..2.. swipegallery.css ... - Google

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

.>. Instantiation and Event Handling<br />

Wait for the Enabler to be initialised:<br />

// Set up our point of entry.<br />

if (Enabler.isInitialized()) {<br />

init();<br />

} else {<br />

Enabler.addEventListener(studio.events.StudioEvent.INIT, init);<br />

}<br />

Instantiating the component is straightforward<br />

function init() {<br />

var gallery = new studio.innovation.components.<strong>Swipe</strong><strong>Gallery</strong>(config);<br />

}<br />

Immediately following instantiation, you can set up listeners and callback for the SLIDE custom event. When a user<br />

slides to an image, the event slideX is raised where X is a number starting from 0 and counting upward depending<br />

on how many images are in the gallery.<br />

gallery.addEventListener('slide0', function() {<br />

console.log('slide0');<br />

Enabler.counter("slide - image 1");<br />

});<br />

gallery.addEventListener('slide1', function() {<br />

console.log('slide1');<br />

Enabler.counter("slide - image 2");<br />

});<br />

gallery.addEventListener('slide2', function() {<br />

console.log('slide2');<br />

Enabler.counter("slide - image 3");<br />

});<br />

gallery.addEventListener('slide3', function() {<br />

console.log('slide3');<br />

Enabler.counter("slide - image 4");<br />

});<br />

.NOTE:. The Enabler.counter() call is a custom Rich Media counter which will appear within the Rich Media report for your creative, allowing you<br />

to easily see which of your images was viewed the most. For more information on setting up Rich Media Counters see our help centre .here.<br />

To actually show the component you must call the render method and supply the parent container. The parent<br />

container can be any valid element.<br />

gallery.render(document.getElementById('gallery'));<br />

Finally, a method is available for you to jump to any slide in the gallery. The two parameters it takes are the slide<br />

index number (starting at index 0) and the animation duration, in milliseconds.<br />

gallery.slide(3, 300);<br />

gallery.slide(2, 3000);<br />

gallery.slide(0, 1000);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!