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

, , ,
About — I'm an enthusiastic software engineer and consultant interested in many fields including J2EE, programming, electronics, 3D printing, video games, wood working and gardening.
See my Resume for more information.
The views expressed in this blog are my own and not those of my employer.
comments powered by Disqus
My other posts you may like...
Programming, DIY, Games, Hacks, Tech and more.
Follow me on...
Current and Past Projects
See my Resume

Subscribe


RSS Feed

My Other Web Sites

Igor and Elise's Travels
Riverside Expressway Cam
StrFunc() Online
300 George St Blogumentary
Guru JSON-RPC Tester
Extrudifier Object Designer

Recent Blog Posts

Binding extra variables with PHP PDO returns no results

New Nintendo 3DS XL, R4i SDHC RTS Lite and DSDoom

Older versions of JD-GUI crashing on macOS Sierra

How does Seeed Fusion stack up as a low budget PCB fab

Where to find the last item (Robbie's lost lyrics) in GravityFalls Lake level

Detecting print requests to print contents of a DIV with JavaScript

Using Google DFP with AdSense on responsive pages

How to change the email subject line in Gmail

Force PHP GD library to load JPEG images that have invalid data

How to uninstall Samsung Smart Switch from your Mac

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

Top Categories

Blogs I follow

Matt Moores Blog
Georgi's FlatPress Guide
Perplexing Permutations
The Security Sleuth

Friends

RAWS Parts Online
Alpha Dimensions Hosting
Kristensen Photography
Ilia Rogatchevski
Travelling Fairy

Blog Activity

Blog Activity
Follow me on... 
     
...or subscribe for updates!

Don't show this again