Comments (5)
Ok, now let assume per different screen size you have different layout for responsive output of your design. Right now there is no native options available to set this quickly. But to achieve this manual control per screen size of setting the type of zoom, we can try next JS code with xZoom API:
(function ($) {
$(document).ready(function() {
function manual_responsive(xzoom) {
var width = $(window).width();
if (width < 500) {
xzoom.options.position = "fullscreen"
} else if (width < 700) {
xzoom.options.position = "bottom"
} else if(width < 960) {
xzoom.options.position = "left"
} else {
xzoom.options.position = "right"
}
}
var instance = $('.xzoom, .xzoom-gallery').xzoom({adaptive: false});
manual_responsive(instance);
$(window).resize(function() {
manual_responsive(instance);
});
});
})(jQuery);
Here, I have created new function manual_responsive
in which I used if
condition scheme per every width I need, to have a manual control on it. Make sure the order of width is in ascendant order. And the last one of them is default.
P.S. Make sure that adaptive
option is set to false
, when you taking manual control over responsive like this one.
from xzoom.
Outstanding, thank you very much for your time and help, your plugin is amazing. This works and has fixed my problem, I would of never worked that out.
(function ($) {
$(document).ready(function() {
function manual_responsive(xzoom) {
var width = $(window).width();
if (width < 992) {
xzoom.options.position = "inside"
} else if(width < 1200) {
xzoom.options.position = "right";
xzoom.options.Xoffset = 5;
xzoom.options.zoomWidth = 655;
xzoom.options.zoomHeight = 420;
} else {
xzoom.options.position = "right";
xzoom.options.Xoffset = 100;
xzoom.options.zoomWidth = 667;
xzoom.options.zoomHeight = 410;
}
}
var instance = $('#main_image, .xzoom-gallery').xzoom({
tint: '#333',
adaptive: false,
smoothZoomMove: 0,
smoothLensMove: 0,
smoothScale: 0,
hover: true,
defaultScale: 0
});
manual_responsive(instance);
$(window).resize(function() {
manual_responsive(instance);
});
});
})(jQuery);
This is my code, I know I could of simplify the syntax for xzoom.options to an $.extend but for easy reading for anyone else new to jQuery, I hope this helps.
from xzoom.
If xZoom is not being used on a webpage it crashes my other Javascript and jQuery that I'm using.
Uncaught TypeError: Cannot set property 'position' of undefined
This error always appears. I'm still using the same script from my previous comment.
from xzoom.
Sorry I fixed it, I wrapped it in an if statement.
if($('#main_image').length === 1) {
//run the script
}
from xzoom.
No problem, thanks for sharing your solution 👍
from xzoom.
Related Issues (20)
- While i'm click the first time small preview it the there is that possible to hide this in mobile devices. HOT 3
- xZoom Lens is not adjusting in small size of image HOT 9
- xZoom lens in mobile HOT 5
- how can I make the zoom result image bigger than the container HOT 2
- rootOutput HOT 2
- Capturing current zoom scale HOT 1
- Page Not Scrolling HOT 1
- Module build failed: ModuleNotFoundError: Module not found: Error: Can't resolve '../images/xloading.gif' in 'C:\Users\fhsna\Projetos de software\lojafinal\loja\node_modules\xzoom\dist' HOT 3
- Add xzoom event on dynamic images HOT 2
- Is it possible to use it with Vue.js? HOT 10
- php laravel HOT 2
- Thumbnail image click not working HOT 1
- Lens is not working - overlapping lens frame on hover HOT 1
- Question - xzoom container size adjustability HOT 1
- i made the thumbnail in left side of the image like amazon but its throwing error in js HOT 2
- Zoom aspect ratio changes when adding image of the same size as of the demo car images HOT 2
- Either cursor is not working or Popup image window position is not right HOT 2
- Perfect plugin ,Why no arrows button HOT 1
- how can use in gulpjs file HOT 1
- Not working over modal HOT 2
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 xzoom.