Solved

how implement camera focus effect in jquery ?

Posted on 2010-11-23
6
568 Views
Last Modified: 2012-05-10
is any one have idea to how implement zoom effect like
this website :http://www.absacapital.com/Pages/AbsaCapital.aspx
0
Comment
Question by:imperlish
  • 3
6 Comments
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 34208073
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 34209118
http://slides.html5rocks.com/ is a great tutorial on how to achieve this using HTML5
0
 

Author Comment

by:imperlish
ID: 34225074
yes like this :http://mrdoob.com/118/Rotozoomer_HTML5
but not moving forward, i need to zoom on div and on event zoomout.
0
 
LVL 42

Accepted Solution

by:
Rob Jurd, EE MVE earned 500 total points
ID: 34503592
That page uses the svg tag and javascript, yoiu should be able to adapt it:

<div id="container"><svg width="1440" height="724"><defs><pattern id="texture" patternUnits="userSpaceOnUse" width="270" height="270" patternTransform="translate(563.0617437339367, 425.58112281380807) scale(0.3939994872616265) rotate( 284.4186557036039)"><image width="270" height="270" preserveAspectRatio="none" href="meanman.png"></image></pattern></defs><rect width="1440" height="724" style="fill:url(#texture)"></rect></svg></div>

Open in new window


<script type="text/javascript">

			var SCREEN_WIDTH = window.innerWidth, SCREEN_HEIGHT = window.innerHeight,
			SCREEN_WIDTH_HALF = SCREEN_WIDTH / 2, SCREEN_HEIGHT_HALF = SCREEN_HEIGHT / 2,
			
			texturePattern;

			init();
			setInterval(loop, 1000/60);

			function init()
			{
				var container, svg;
				
				container = document.getElementById('container');

				svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
				svg.setAttribute('width', SCREEN_WIDTH);
				svg.setAttribute('height', SCREEN_HEIGHT);

				var defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
				svg.appendChild(defs);

				texturePattern = document.createElementNS('http://www.w3.org/2000/svg', 'pattern');
				texturePattern.setAttribute('id', 'texture');
				texturePattern.setAttribute('patternUnits', 'userSpaceOnUse');
				texturePattern.setAttribute('width', 270);
				texturePattern.setAttribute('height', 270);
				defs.appendChild(texturePattern);

				var texture = document.createElementNS('http://www.w3.org/2000/svg', 'image');
				texture.setAttribute('width', 270);
				texture.setAttribute('height', 270);
				texture.setAttribute('preserveAspectRatio', 'none');	
				texture.setAttributeNS('http://www.w3.org/1999/xlink', 'href', 'meanman.png');
				texturePattern.appendChild(texture);
				
				var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
				rect.setAttribute('width', SCREEN_WIDTH);
				rect.setAttribute('height', SCREEN_HEIGHT);
				rect.setAttribute('style', 'fill:url(#texture)');
				svg.appendChild(rect);
				
				container.appendChild(svg);
			}

			function loop()
			{
				var timer, scale, tx, ty, rotate;
			
				timer = new Date().getTime();

				tx = SCREEN_WIDTH_HALF + Math.sin(timer * 0.0001) * 256;
				ty = SCREEN_HEIGHT_HALF + Math.cos(timer * 0.0002) * 256;
				scale = (Math.sin(timer * 0.0002) + 1.1) * 3;
				rotate = Math.cos(timer * 0.0001) * 360;			

				texturePattern.setAttribute('patternTransform', 'translate(' + tx + ', ' + ty + ') scale(' + scale + ') rotate( ' + rotate + ')');
			}
	
		</script>

Open in new window

0
 
LVL 31

Expert Comment

by:James Murrell
ID: 36434003
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Several part series to implement Internet Explorer 11 Enterprise Mode
The viewer will learn how to dynamically set the form action using jQuery.
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question