我在我的phonegap应用中使用magnific popup
。
这就是我使用它的方式
<div class="comment-div">
<a class="image-link"href="http://webcareinfoway.com/images/Web_pics/android-logo-transparent.png">
<img src="http://webcareinfoway.com/images/Web_pics/android-logo-transparent.png" alt="Smiley face"></a>
</div>
<div class="comment-div">
<a class="image-link"href="https://image.freepik.com/free-icon/apple-logo_318-40184.jpg">
<img src="https://image.freepik.com/free-icon/apple-logo_318-40184.jpg" alt="Smiley face"></a>
</div>
<div class="comment-div">
<a class="image-link"href="https://s-media-cache-ak0.pinimg.com/736x/33/b8/69/33b869f90619e81763dbf1fccc896d8d.jpg">
<img src="https://s-media-cache-ak0.pinimg.com/736x/33/b8/69/33b869f90619e81763dbf1fccc896d8d.jpg" alt="Smiley face"></a>
</div>
我已经从github中包含了所需的JS和CSS文件。
我的脚本如下所示。
$(document).ready(function() {
$('.image-link').magnificPopup({
type: 'image',
mainClass: 'mfp-with-zoom', // this class is for CSS animation below
gallery:{
enabled:true
,
zoom: {
enabled: true, // By default it's false, so don't forget to enable it
duration: 300, // duration of the effect, in milliseconds
easing: 'ease-in-out', // CSS transition easing function
opener: function(openerElement) {
return openerElement.is('img') ? openerElement : openerElement.find('img');
}
}
});
});
当我在Android手机上运行并点击图片时,图片只会在浏览器中打开,而不是按照图库打开。
我做错了什么?
答案 0 :(得分:0)
$(document).ready(function() {
$('.image-link').magnificPopup({
type: 'image',
mainClass: 'mfp-with-zoom', // this class is for CSS animation below
gallery:{
enabled:true,
zoom: {
enabled: true, // By default it's false, so don't forget to enable it
duration: 300, // duration of the effect, in milliseconds
easing: 'ease-in-out', // CSS transition easing function
opener: function(openerElement) {
return openerElement.is('img') ? openerElement : openerElement.find('img');
}
}
}
});
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.js"></script>
<div class="comment-div">
<a class="image-link" href="http://webcareinfoway.com/images/Web_pics/android-logo-transparent.png">
<img src="http://webcareinfoway.com/images/Web_pics/android-logo-transparent.png" alt="Smiley face"></a>
</div>
<div class="comment-div">
<a class="image-link"href="https://image.freepik.com/free-icon/apple-logo_318-40184.jpg">
<img src="https://image.freepik.com/free-icon/apple-logo_318-40184.jpg" alt="Smiley face"></a>
</div>
<div class="comment-div">
<a class="image-link"href="https://s-media-cache-ak0.pinimg.com/736x/33/b8/69/33b869f90619e81763dbf1fccc896d8d.jpg">
<img src="https://s-media-cache-ak0.pinimg.com/736x/33/b8/69/33b869f90619e81763dbf1fccc896d8d.jpg" alt="Smiley face"></a>
</div>
&#13;
请检查代码。
我用于magnificPopup的CDN主要有变化 请在magnificPopup CDN之前添加 jquery
感谢希望对你有用