Igor's Blog
Programming, DIY, Games, Hacks, and Tech

After going away on a trip to the mountains and testing out my Travel µBlog software for the first time it was clear that some improvements were needed in terms of how photos are displayed. The main issue I noticed was that photos taken on a Galaxy S6 were 1080p and hence wide screen. This didn't play well with the 4:3 aspect ratio sized photo boxes used on the blog.

I decided that the best way to handle this was to have these widescreen photos be scrollable somehow. I tried out scripts like panoramaviewer.js and jquery.panr as well as a few others but none of them were exactly what I was looking for. So after a little bit of light reading I decided to create my own jQuery UI Plugin.

Introducing the jQuery UI Photoboxr Plugin...
screenshot.jpg


This plugin creates a constant ratio (4:3) box around a photo. It determines whether the photo is landscape or portrait and lets you scroll it accordingly if its dimensions exceed the size of it's wrapping DIV.

There are overlay indicators for scroll direction which also double up as on/off toggles for scrolling. There is integration for Fancybox to create galleries and photo pop ups too.

Using it is easy. All you need to start is an DIV element with a size defined. This will be the container for any images added by the plugin.
 HTML
<div id="photoboxr-container" style="width: 100%;">
</div>


Then the JavaScript is similar to any other jQuery UI plugin, simply call the .photoboxr() method to initialise it. I create an Image object but it could be done on an <img> element too. After the plugin is initialised, the 'wrapper' method is used to fetch the wrapping DIV around the image, which can then be added to the container.
 JavaScript
var container = $('#photoboxr-container');
$(new Image()).photoboxr({
src: 'fog_panorama.jpg',
wrapSizingClass: 'ui-pbxr-half'
})
.photoboxr('wrapper')
.appendTo(container);




There are other options available that can be passed to the plugin, these are documented on GitHub.

This plugin works well for me, it's not as versatile as some of the other panoramic view plugins out there, but that was not the point of it. There are some minor issues with it still that I will address over time so keep an eye out for future updates.

-i

comments powered by Disqus
Other posts you may like...

Recent Blog Posts

A hack to create an uber jar with the Maven Shade Plugin using local jar files

Is it worth it? Apple USB-C Digital Multi AV adapter vs a cheap eBay clone

Running X11 graphical applications after changing to another user using 'sudo su'

How to stop Facebook using ad images as post sharing thumbnails

Picking lists for Atari Lynx capacitor replacement kits

Performance - 2012 Retina MacBook Pro vs 2017 MacBook Pro

Look and feel - 2012 Retina MacBook Pro vs 2017 MacBook Pro

Using math to work out the diameter of hard to reach water cooling pipes

How to get the unreachable shard in the Hinterlands in DragonAge Inquisition

Measy RC12 wireless 2.4Ghz keyboard touchpad review

Recent Galleries

Monument Valley 2 is released and does not disappoint

Space Food - Chocolate Ice Cream with Chocolate Chips

Legeod Star Wars AT-DP kit

DIY spare parts computer build with a RAIDMAX Anura case

Fake 'Lepin' brand Lego packaging

Hardwood garden bench with clear resin void filler

Fixing a 3D printer extruder that stopped heating up

Easily increase disk space in a Lenovo Ideapad 100S 14" laptop with an M.2 SSD

Making a multi-piece 3D printed solder spool holder stand

DIY indoor apartment grow light wiring

My Other Web Sites

Igor and Elise's Travels
Riverside Expressway Cam
300 George St Blogumentary

My Online Tools

UUID to OID Converter
Guru JSON-RPC Tester
Extrudifier Object Designer
Travel ┬ÁBlog

Blogs and Friends

Matt Moores Blog
Georgi's FlatPress Guide
Perplexing Permutations
The Security Sleuth
Ilia Rogatchevski
Travelling Fairy

Blog Activity

Blog Activity
Don't forget to
me for more great articles!
Don't show this again