nicekei / jquery-html5-canvas-panorama-plugin Goto Github PK
View Code? Open in Web Editor NEWA tiny jQuery plugin that helps displaying panorama images
A tiny jQuery plugin that helps displaying panorama images
jQuery-html5-canvas-panorama-plugin From June 11 2012 from Kei Kim([email protected]) Added a sample page users can directly view on the net Check following pages to see ddpanorama in action: https://htmlpreview.github.io/?https://github.com/nicekei/jQuery-html5-canvas-panorama-plugin/blob/master/sample.dynamicspeed.html https://htmlpreview.github.io/?https://github.com/nicekei/jQuery-html5-canvas-panorama-plugin/blob/master/sample.eventredraw2.html (NEW) https://htmlpreview.github.io/?https://github.com/nicekei/jQuery-html5-canvas-panorama-plugin/blob/master/sample.drawlabels.html (NEW) https://htmlpreview.github.io/?https://github.com/nicekei/jQuery-html5-canvas-panorama-plugin/blob/master/sample.event.html https://htmlpreview.github.io/?https://github.com/nicekei/jQuery-html5-canvas-panorama-plugin/blob/master/sample.eventredraw.html https://htmlpreview.github.io/?https://github.com/nicekei/jQuery-html5-canvas-panorama-plugin/blob/master/sample.dynamicsize.html https://htmlpreview.github.io/?https://github.com/nicekei/jQuery-html5-canvas-panorama-plugin/blob/master/sample.dynamicinteractive.html https://htmlpreview.github.io/?https://github.com/nicekei/jQuery-html5-canvas-panorama-plugin/blob/master/sample.pos.html https://htmlpreview.github.io/?https://github.com/nicekei/jQuery-html5-canvas-panorama-plugin/blob/master/sample.loop.html https://htmlpreview.github.io/?https://github.com/nicekei/jQuery-html5-canvas-panorama-plugin/blob/master/sample.basic.html https://htmlpreview.github.io/?https://github.com/nicekei/jQuery-html5-canvas-panorama-plugin/blob/master/sample.minspeed.html https://htmlpreview.github.io/?https://github.com/nicekei/jQuery-html5-canvas-panorama-plugin/blob/master/sample.size.html https://htmlpreview.github.io/?https://github.com/nicekei/jQuery-html5-canvas-panorama-plugin/blob/master/sample.interactive.html <Version history> 1.43 : Fixed a bug firing ddredraw event first when minSpeed exists(!=0) 1.42 : Fixed scrollX to be always within (-width*0.5, width*0.5) for the looped image, so that users can more conveniently draw stuffs using this parameter. Examples: ex1) width:100, scrollX:90 -> -10 ex2) width:100, scrollX:-60 -> 40 Now ddpanorama uses imagesLoaded script to catch the image load event. As the load event has some drawbacks(https://api.jquery.com/load-event/), I decided to adapt other method. eg. Prior to this version, applying ddpanorama after the image is fully loaded was not working well, but it now just works Added html element overlay example. Now you can see other elements positioned over canvas element. Other way of implementation might be drawing some texts on canvas and checking if the user clicks one of those texts’ bounding rectangles, but it would be definitely cumbersome/hard to predict the final result. Instead, I positioned already existing handy HTML elements on top of canvas, so that users can see/control the result beforehand. 1.41 : Delayed resizing/attachment after the panorama image is completely loaded 1.40 : Now CSS is separated from codes. Note that to work as before, you need to include "ddpanorama.css" as a stylesheet in your pages Event prefix is changed from "ddpanorama_" to "dd". eg. ddpanorama_redraw -> ddredraw "init" event is added which is called when the canvas is initialized - a good place to retrieve canvas and apply any additional properties to it In case the interactive flag is turned off, the panning cursor didn't showup in Webkit browsers(up to 1.31). This is fixed in the current version. Event demo(sample.event.html) code is rewritten. Now you can check all the event life cycles ("startmove", "stopmove", "mousedown", "mouseup" events are added) Fullscreen demo(sample.dynamicsize.html) code is refactored to show the demonstration clearly. Note that the ugly bottom scroll bar is gone by CSS's blessing (width:100%) Redraw event demo(sample.eventredraw.html) shows how to draw something on top of the panorama Refactored codes to support changing "defaults" which decides panoramas' default parameters 1.31 : Size change is also supported 1.30 : Support changing panorama parameters after it is created 1.24 : Fixed a scroll variable becoming NaN issue when load event is fired later 1.23 : Added startPos parameter. You can specify relative value to (imageWidth-canvasWidth). So you specify 1.0, you get the 100% scrolled image 1.22 : Changed parameter names to reduce ambiguity loopBounce -> bounce loopBorderRate -> bounceEdge loopBorderColor -> bounceEdgeColor Refactored sample htmls. Made them being generated from parameters. 1.21 : Added {loop:false} option to support not-wrapped image with a nice bounce effect (due to a user request: thanks baloneysandwiches) Split sample html pages into multiple files to show what it is clearly in details 1.12 : Added autoscroll feature(minSpeed parameter) Added interactive flag(interactive parameter) Fixed image to canvas converting method. Now use $.after to properly handle canvas insertion 1.11 : Fixed scroll popping bug 1.10 : Fixed event handling bug(mis typo?) Support resized canvas drawing when height is specified Fills the black color when canvas image is not loaded yet Added .loaded parameter to event, users can draw something until the panorama image is fully loaded 1.01 : Added event handling support 1.00 : Started ddpanorama <Q & A> Q. Why do you re-create already existing jQuery panorama plugin? Yeah, it's another jQuery panorama plugin! But the implementation details are quite different. As the repo name implies, it internally changes image into html5 canvas. Users can drag and view 360 degree panorama through the canvas. Q. Why canvas? Aren't image with css and javascript sufficient? Probably correct. I chose html5 canvas for two reasons: 1. If we draw things on canvas, we can do pretty cool stuffs with it like applying cool effects on it. 2. Drawing things on html5 canvas is fast enough on today's mobile device. (I want this plugin get spread :D So I added the last but not least important notes) *. It scrolls smoothly(maybe smoother than others) *. It scrolls like iOS scrollview Q. So what's the jQuery plugin name? jQuery-html5-canvas-panorama? No, that's too long. Because it's jQuery plugin, it should start with "j". But I prefer "dd", which means "dance dance". So the name is "ddpanorama" Strange enough, but this is named after an amateur photograph's blog I love I want to support that photos being displayed on the web I'll create a series of tools and plugins to support Let's dance! :D Q. What is jquery.ba-outside-events? Is it part of the plugin? No, absolutely not. It's a prerequisite jQuery plugin which handles outside events ex) outside mouse release event It's a simple and works good. The author's page is here(http://benalman.com/projects/jquery-outside-events-plugin/) Maybe later it can be included in jQuery itself! Check the new version if you have a time. I included "jquery.ba-outside-events.min.js" file in the repository which works currently with ddpanorama.
Calling ddpanorama over dynamically added images in onload handler doesn't work.
This issue is related to the imagesLoaded plugin.: desandro/imagesloaded#147
If this issue is not fixed by the author, there should be a workaround way to this problem.
Hello,
this plugin don't have zoom option?
First of all: really nice work!! Very smooth and intuitive.
May it be possible in one of the next releases to place Links into the Panorama to realise a virtual tour through a building or things like that?
Similar to this one: http://www.openstudio.fr/jquery-virtual-tour/sculpteur.html but smooth like yours ;)
In Firefox 13, when I hover over a panorama, I get a hand cursor. When I click and drag, it stays a hand. Okay.
But in Chrome 20, when I hover, I get the four-arrows-in-all-directions cursor. It's similar to what Mozilla calls the "all-scroll" cursor, though not quite the same. When I'm actively clicking, during the drag, the cursor becomes an I-beam, for indicating that text can be selected. This is awkward and feels out of context.
For semantics, since you can't scroll vertically, it really might make more sense to have what Mozilla calls "ew-resize". And keep it that way during the drag. See:
This plugin interests me because it seems to work on the iPad (from your demo page), but I am having no luck getting it to work in my own development environments. I'm loading jquery 1.7.2, then ba-outside-events, then ddpanorama.min.js, and then ddpanorama.gensample.js... then when trying to emulate your calls to addSamplePano, the images load just fine, but there is no interactivity and chrome reports the following error:
Uncaught TypeError: Object [object Object] has no method 'ddpanorama'
Am I doing something wrong?
Thanks for the amazing quick responses, Kei. It works beautifully. Amazing! I have a few more ideas for you. I've separated them into separate issues.
The first, this idea, is to allow the specification of a start position. Right now it always starts at X=0 of the original img. This is especially important if you're not looping. I want to be able to start the image in the center of the img, so that the viewer can drag left or right from the initial position.
is there a way to make it works with variable dimensions ?
full screen for exemple
This is a pretty standard option on other panorama plug-ins. This is a dealbreaker for me at the moment...
Distortion in original images don't mean that it should be displayed as distorted
it would be cool, if we handle the image's distortion before displaying the image.
Users must configure the panorama image's meta information(something about the distortion of their image to be displayed) beforehand. Some kind of web based configuration tool can be exposed to user to ease this task.(rendering)
I think it's not easy doing this with 2d canvas, so we should think about how to implement the rendering part.
Maybe we can include the users's view parameters(perspective? location? etc) when calculating the expected rendering result.(configuring)
See http://wiki.panotools.org/Projections#Pannini_projection to find more information about image distortions.
or may be free to explore kind of thing
Currently to get the original image size, ddpanorama uses naturalWidth,naturalHeight properties.
But these do not exist in some browsers - especially IE.
We need a workaround for these cases.
is it possible to have something like a left / right button outside the canvas? so if a user clicks the right button it kinda "simulates" the drag to the left (scrolls to the right)?
I use the panorama-plugin following the demo in the sample.pos.js. But the image is static. The difference is that I move the javascript code from body to head.
Any suggestion. Thanks in advance.
It is weird that I can not paste/type html code in the comment.
I follow the eventredraw example and it works fine on the local machine. Then I push all files on my server and try to operate remotely. I got an error message: SyntaxError: syntax error. http://192....../src/imagesloaded.pkgd.min.js . I googled and consider the possible reason, which is the javascript file being treated as html file and not been loaded. I don't know how to remove this error. Any suggestions? Thanks in advance!
My code is:
<title>Chinese Characters</title> <script type="text/javascript" src="./src/jquery.1.7.1.min.js"></script> <script type="text/javascript" src="./src/jquery.ba-outside-events.min.js"></script> <script type="text/javascript" src="./src/ddpanorama.min.js"></script> <script type="text/javascript" src="./src/imagesloaded.pkgd.min.js"></script> <script type="text/javascript"> function load() { window.addEventListener("message", receiveMessage, false); if (opener && !opener.closed) { opener.postMessage('ready', "http://localhost"); } } function receiverMessage(event) {
if (event.origin !== "http://localhost") {
return;
}
var data = event.data;
var image ="./images/" + data;
var img = document.createElement("img");
img.src = image;
document.body.appendChild(img);
jQuery(function() { jQuery("img").ddpanorama({ ratio: 9/16}).bind("ddredraw", function(event) ......
.....
</script>
</head>
<body onload="load()">
</body>
I find the name "loopBorderRate" really confusing. It's neither loop-related, nor border-related, nor rate-related. For example, it works even when "loop" is turned off. "Border" has such a specific meaning in CSS. I'm not sure that's the right word for this. And "rate" usually means something related to time, which this isn't. Hmm... What about calling it 'sideWall' or 'edgeThickness' or something like that?
I finally got what I wanted doing this:
$("#panorama").ddpanorama({width:644, height:500, loop:false, loopBounce:false, loopBorderRate:0});
But weirdly, when I tried leaving out the 'loopBorderRate' option entirely:
$("#panorama").ddpanorama({width:644, height:500, loop:false, loopBounce:false});
I got what looks a lot like a massive 80% border at both edges. It's counter to expectations. What value is it defaulting to? I figured out that when it is specified, it buffers the image with a thickness that is a percentage of the overall width. I don't completely understand what the use case is for this, but okay.
Thanks again. I hope this feedback helps! I really love how smooth it is. I bet this is going to be very popular.
Hi! your plugin is great but it could be better if it work also for ie8 (steal to many XP user)
Would be awesome if the callback for this had more information about the panorama's current state. i.e. it's x/y coordinate of the image
You might know this already but i wanted to inform you that in file https://github.com/nicekei/jQuery-html5-canvas-panorama-plugin/blob/master/ddpanorama.css there are several CSS errors.
Line 1: Wrong comment style
Line 3: Missing semikolon, wrong comment style
Line 6: Wrong comment style
Line 3/15: References to not existing images (openhand.cur, closedhand.cur)
i would like use jQuery-html5-canvas-panorama-plugin (sample Basic) for showing some Panorama images on my website.
The test i made looks very good, perfect,
But the only thing is, that it appers now above the Image {"width":1000,"height":520,"loop":false,"bounceEdge":0.3}
What can i do, that this not appears on the website ?
thanks
Josef
Hi there, is there a way that this plugin works on IE, i've been trying on 7 & 8 but not at all.
Hi,
ddpanorama works prefect for images like PanoSarek.jpg (128k). But when I use ddpanorama to show a large image with size 17.5 MB. It runs slowly and firefox shows "A script on this page maybe busy,... ddpanorama.min.js:9." Do I miss something that causes the page running slowly? Any suggestion is very welcome!
I have got 4 images on this page, each one hidden behind a tab. Sometimes they all load, sometimes none of them load. It may be that sometimes SOME of them load, but cannot remember.
http://roa.mstarhost.com/surgery-center/
Any suggestions on what is going on? Is there a time-out happening? I realize the images are fairly large, but not gigantic. Any way to reload them if it times out?
This is a really cool plug-in. The scrolling is insanely smooth, which is great.
One question I have is about browser support. Could you take this on a tour through browserstack (or some such) and tell us the precise browser support? There are multiple levels of canvas support in the various browsers, so it would be really useful to know in advance. Like you say, there are lots of plug-ins that do this, so it would help developers to compare.
I want to be able to control how far and for how long the panorama keeps traveling after I fling it with the mouse/touchpad. The option should be a numeric value, within some stated range. Maybe [0..100]
The reel rotation plugin has something like this. They call it 'brake':
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.