var container = Prime.Document.queryByID('container');
var queue = Prime.Document.queryByID('queue');
var viewFinder = Prime.Document.queryByID('view-finder');
var body = new Prime.Document.Element(document.body);
var thumbnails = [];
body.addEventListener('keydown', function(event) {
if (event.keyCode === 37) {
// left
var margin = Prime.Utils.parseCSSMeasure(queue.getComputedStyle()['margin-left']);
queue.setStyle('margin-left', (margin + width) + 'px');
} else if (event.keyCode === 39) {
// right
var margin = Prime.Utils.parseCSSMeasure(queue.getComputedStyle()['margin-left']);
queue.setStyle('margin-left', (margin - width) + 'px');
}
}, this);
for (var i=0; i < 30; i++) {
queue.appendHTML('<div>' + i + '</div>');
thumbnails.push(queue.queryLast('div'));
}
var width = queue.queryFirst('div').getOuterWidth();
var marginLeft = (container.getWidth() / 2) - (viewFinder.getWidth() / 2);
// margin should be a multiple of the width
viewFinder.setStyle('margin-left', ((Math.floor(marginLeft / width) * width) - 5) + 'px');
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.