将动画添加到图像更改 [英] Adding animation to image change

查看:81
本文介绍了将动画添加到图像更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在opencart中实现了一个扩展,该扩展使我可以单击缩略图来更改主图像,唯一的问题是,只需更改完全没有动画或过渡效果的图像,我可以这样做图片滑入其中,是否有必要添加到我已经拥有的代码中,以便我可以做到这一点?

I have just implemented an extension in opencart which allows me to click on a thumbnail to change the main image, the only problem is, is just changes the image which no animation or transition effect at all, I would to make it so that the images slide in, is there anyway to add to the code I already have so that I can do that?

这是mod的代码:

<file name="catalog/controller/product/product.php">
        <operation>
            <search position="after"><![CDATA['popup' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height')),]]></search>
            <add><![CDATA[// BOF om_Thumb_image_swap.xml
'addthumb' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height')),
// EOF om_Thumb_image_swap.xml]]></add>
        </operation>
    </file>

    <file name="catalog/view/theme/nthwondr_2013/template/product/product.tpl">
        <operation>
            <search position="before"><![CDATA[<?php echo $footer; ?>]]></search>
            <add><![CDATA[<!-- BOF om_Thumb_image_swap.xml -->
<?php if ($images) { ?>
<script type="text/javascript"><!--
$(function(){
    var imgs = <?php echo json_encode($images); ?>;
    var html = '';
    $.each(imgs,function(i,image){
        html += '<div class="image" style="display:none;"><a href="' + image.popup + '" title="<?php echo $heading_title; ?>" class="colorbox">';
        html += '<img src="' + image.addthumb + '" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" /></a></div>';
        $('.image-additional').before(html);
        html = '';
    })
    html = '<a href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>">';
    html += '<img src="<?php echo $thumb; ?>" width="<?php echo $this->config->get('config_image_additional_width'); ?>" height="<?php echo $this->config->get('config_image_additional_height'); ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" style="padding-left: 2px;" /></a>';
    $('.image-additional').prepend(html);
    var images = $('div.left .image');
    var thumbs = $('.image-additional a');
    thumbs.removeClass('cboxElement').removeClass('colorbox');
    images.children('a').colorbox({rel:'colorbox'});
    thumbs.on('click',function(e){
        e.preventDefault();
        images.hide();
        images.eq(thumbs.index(this)).show();
    });
});
//--></script>
<!-- EOF om_Thumb_image_swap.xml -->
<?php } ?>]]></add>
        </operation>
    </file>

谢谢大家的帮助.

推荐答案

您可以使用此

thumbs.on('click',function(e){
        e.preventDefault();
        images.hide('slide', {direction: 'left'}, 1000);
        images.eq(thumbs.index(this)).show('slide', {direction: 'left'}, 1000);
    });

这篇关于将动画添加到图像更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆