基于Jquery和html5实现炫酷的3D焦点图动画

2020-05-27 18:09:57易采站长站整理

box-shadow: 0px 10px 20px rgba(0,0,0,0.3);
}
.dg-wrapper a.dg-transition{
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
-ms-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
.dg-wrapper a img{
display: block;
padding: 41px 0px 0px 1px;
}
.dg-wrapper a div{
font-style: italic;
text-align: center;
line-height: 50px;
text-shadow: 1px 1px 1px rgba(255,255,255,0.5);
color: #333;
font-size: 16px;
width: 100%;
bottom: -55px;
display: none;
position: absolute;
}
.dg-wrapper a.dg-center div{
display: block;
}
.dg-container nav{
width: 58px;
position: absolute;
z-index: 1000;
bottom: 40px;
left: 50%;
margin-left: -29px;
}
.dg-container nav span{
text-indent: -9000px;
float: left;
cursor:pointer;
width: 24px;
height: 25px;
opacity: 0.8;
background: transparent url(../images/arrows.png) no-repeat top left;
}
.dg-container nav span:hover{
opacity: 1;
}
.dg-container nav span.dg-next{
background-position: top right;
margin-left: 10px;
}

JavaScript代码


/**
* jquery.gallery.js
* Copyright 2011, Pedro Botelho / Codrops
* Free to use under the MIT license.
*
* Date: Mon Jan 30 2012
*/

(function( $, undefined ) {

/*
* Gallery object.
*/
$.Gallery = function( options, element ) {

this.$el = $( element );
this._init( options );

};

$.Gallery.defaults = {
current : 0, // index of current item
autoplay : false,// slideshow on / off
interval : 2000 // time between transitions
};

$.Gallery.prototype = {
_init : function( options ) {

this.options = $.extend( true, {}, $.Gallery.defaults, options );

// support for 3d / 2d transforms and transitions
this.support3d = Modernizr.csstransforms3d;
this.support2d = Modernizr.csstransforms;
this.supportTrans = Modernizr.csstransitions;

this.$wrapper = this.$el.find('.dg-wrapper');

this.$items = this.$wrapper.children();
this.itemsCount = this.$items.length;

this.$nav = this.$el.find('nav');
this.$navPrev = this.$nav.find('.dg-prev');
this.$navNext = this.$nav.find('.dg-next');

// minimum of 3 items
if( this.itemsCount < 3 ) {

this.$nav.remove();
return false;

}

this.current = this.options.current;

this.isAnim = false;

this.$items.css({
'opacity' : 0,
'visibility': 'hidden'
});

this._validate();

this._layout();

// load the events
this._loadEvents();

// slideshow
if( this.options.autoplay ) {

this._startSlideshow();