Igor's Blog

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...
Programming, DIY, Games, Hacks, and Tech

Recent Blog Posts

Converting a CSV file containing commas in quotes to a pipe separated file using Awk and Bash

How to get Facybox gallery popup to work for images with dynamic URLs

jQuery UI Photoboxr plugin updated to version 0.2

Learn How to Add Disclaimer to All Outgoing Emails in Office 365

How to securely host your web site for free with Google Cloud and CloudFlare (part 3)

How to securely host your web site for free with Google Cloud and CloudFlare (part 2)

How to securely host your web site for free with Google Cloud and CloudFlare (part 1)

Beware of the subtle difference in date format strings between MySQL and SQLite

Postman reporting Unexpected 'N' error in response body

Adding extra shelves to the Ikea Detolf display cabinet

Recent Galleries

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

Good Friday Electronics fun Easter Bunny LED PCB Kit IBEABU-01.0

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
Please follow me for more great content!
     
Don't show this again