Comments (6)
Hi chxcore!
Does the page load the script before the css or after? See what happens when the css is loaded first.
Another method is to make sure all images are loaded before initializing the plugin. This is done by using the window load event instead of the document ready event:
$(window).load(function(){
$('#zoom').anythingZoomer();
});
If that doesn't work is there a particular browser you're seeing this issue in? Could you share some code or a demo of this issue.
Thanks!
from anythingzoomer.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>Anythingzoomer Test Page</title>
<link rel="stylesheet" href="/css/anythingzoomer.css" />
<style>
#zoom .small img{
width: 300px;
}
#zoom .large img{
width: auto;
}
</style>
</head>
<body>
<div id="zoom">
<div class="small">
<img src="http://2.bp.blogspot.com/-ujddJNQ7hBU/T6LKuxhQsLI/AAAAAAAAFNU/RwdvAUH-D7c/s1600/mountains-wallpaper-6.jpg" />
</div>
<div class="large">
<img src="http://2.bp.blogspot.com/-ujddJNQ7hBU/T6LKuxhQsLI/AAAAAAAAFNU/RwdvAUH-D7c/s1600/mountains-wallpaper-6.jpg" />
</div>
</div>
<script type="text/javascript" src="/js/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="/js/jquery.anythingzoomer.min.js"></script>
<script type="text/javascript">
$("#zoom").anythingZoomer();
</script>
</body>
</html>
you will notice that it will work sometimes after the page is loaded, and not others. On the times when it doesn't work, you will notice that the height is set to 0 in the style attribute for az-wrap-inner and az-overly. For me it is working about 50% of the time.
However, if you add height to my css, then the code works 100% of the time.
I do not see the problem in any version of Firefox of IE at my disposal. The issue has been noticed on Chrome 19.0.1084.56 m and Safari (Windows) 5.1.7 (7534.57.2).
from anythingzoomer.
AnythingZoomer isn't being initialized inside of a document ready nor a window load function, it should look like this:
<script type="text/javascript">
$(function(){
$("#zoom").anythingZoomer();
});
</script>
from anythingzoomer.
Initializing inside of a document ready or window load function doesn't solve this particular issue. A friend of mine brought it to my attention that although the DOM might be ready, images could still be processing, giving the 0 height. If I wish to only set one dimension in CSS (in this case width), then I need to make sure the image is fully loaded before allowing the anythingZoomer to start. Here is a StackOverflow question that gives some insight into the problem: http://stackoverflow.com/questions/1257385/javascript-know-when-an-image-is-fully-loaded
Also, its important to note that I only see this issue in Chrome and Safari.
from anythingzoomer.
Well, you could always try an images loaded script. Check out David Desandro's or my version (which uses a different method). What the script does is update the zoomer once all of the images have completed loading.
Here is a demo, and the script to use:
var zoomer = $('#zoom');
// initialize anythingZoomer
$(window).load(function(){
zoomer.anythingZoomer();
});
// update after all images have loaded
zoomer.find('img').imagesLoaded(function(){
// console.debug('all images loaded');
zoomer.anythingZoomer();
});
from anythingzoomer.
I'm guessing this issue has been resolved. Please feel free to reopen it if you continue to have problems.
from anythingzoomer.
Related Issues (20)
- Large Container Positioning Problem
- div contets HOT 1
- Different sizes images HOT 4
- Zoom displays large image only HOT 2
- conflicts with jquery wrapAll() HOT 1
- Hover doesnot work properly when -transform-rotate is done HOT 6
- Using zoom in multiple stacked images for Chrome / Safari HOT 5
- Plugin not showing zoom window when implemented on bootstrap modal HOT 2
- Issue while rotating image. HOT 4
- image map HOT 3
- Is it possible to rotate zoomer automatically on page load HOT 4
- Cloned Image Offset HOT 3
- Responsive Image HOT 4
- Magnifying svgs HOT 8
- Enable/Disable Anything Zoomer HOT 1
- Show coordinates of large image HOT 6
- Make zoomDim configurable in options HOT 1
- Zooming over input/radio elements HOT 8
- How to use dynamic id based this plugin ? HOT 1
- Canvas compatibility ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from anythingzoomer.