左右切换js
2021-01-14 16:15
标签:lse jquery poi aci max val ima ext css (function($) { }, } }).addClass(‘left‘).css(‘opacity‘, ‘0.5‘).hover(function() { } }).addClass(‘right‘).css(‘opacity‘, ‘0.5‘).hover(function() { }))); }); }); allElements = $(allElements); wrapper.append($(el)); }); }); forwardbutton.click(function() { } }); } }); } function getDimensions(value) { } } }); })(jQuery); 左右切换js 标签:lse jquery poi aci max val ima ext css 原文地址:https://www.cnblogs.com/lanlanJser/p/13424047.html
$.fn.extend({
slider: function(options) {
var settings = $.extend({
speed: 500
options);
return this.each(function() {
var slidercontents = $(this).addClass(‘image-slider-contents‘);
var slider = $(‘
var backbutton = $(‘‘).addClass(‘image-slider-back‘);
var forwardbutton = $(‘‘).addClass(‘image-slider-forward‘);
slidercontents.removeAttr(‘id‘);
slidercontents.before(slider);
slider.append(backbutton);
slider.append(slidercontents);
slider.append(forwardbutton);
var total = $(‘> div‘, slidercontents).length;
var left = 0;
var w;
var width;
var maxScroll;
slider.append($(‘‘).css(‘display‘, ‘none‘).addClass(‘preview‘).append($(‘‘).addClass(‘img-large‘)
.append($(‘‘).html(‘ ‘).click(function(e) {
e.stopPropagation();
e.stopImmediatePropagation();
//display previous image
var img = $(this).parent().find(‘img‘);
var index = parseInt(img.attr(‘class‘));
img.removeAttr(‘class‘);
if (index > 1) {
index--;
var src = $(‘.‘ + index + ‘ div img‘).attr(‘src‘);
var txt = $(‘.‘ + index + ‘ div a‘).html();
$(‘.preview‘).find(‘.label‘).html(txt);
$(‘.preview‘).find(‘img‘).addClass(‘‘ + (index) + ‘‘).css(‘opacity‘, ‘0‘).attr(‘src‘, src).stop(false, true).animate({
opacity: 1
},
1000);
else
$(‘.preview‘).find(‘img‘).addClass(‘‘ + (index) + ‘‘);
$(this).css(‘opacity‘, ‘1‘)
},
function() {
$(this).css(‘opacity‘, ‘0.5‘)
}))
.append($(‘
e.stopPropagation();
e.stopImmediatePropagation();
//display next image
var img = $(this).parent().find(‘img‘);
var index = parseInt(img.attr(‘class‘));
img.removeAttr(‘class‘);
if (index index++;
var src = $(‘.‘ + index + ‘ div img‘).attr(‘src‘);
var txt = $(‘.‘ + index + ‘ div a‘).html();
$(‘.preview‘).find(‘.label‘).html(txt);
$(‘.preview‘).find(‘img‘).addClass(‘‘ + (index) + ‘‘).css(‘opacity‘, ‘0‘).attr(‘src‘, src).stop(false, true).animate({
opacity: 1
},
1000);
else
$(‘.preview‘).find(‘img‘).addClass(‘‘ + (index) + ‘‘)
$(this).css(‘opacity‘, ‘1‘)
},
function() {
$(this).css(‘opacity‘, ‘0.5‘)
}))
.append($(‘‘))).append($(‘
.append($(‘‘).addClass(‘close‘).click(function(e) {
$(this).parent().fadeOut("slow");
$(document).click(function(e) {
if ($(‘.preview‘).css(‘display‘) == ‘block‘)
$(‘.preview‘).fadeOut("slow");
function initialize() {
var tempElements = $(‘> div‘, slidercontents);
var allElements = new Array();
tempElements.each(function(index, el) {
allElements.push($(‘
$(‘> div‘, slidercontents).remove();
var wrapper = $(‘
allElements.each(function(index, el) {
slidercontents.append(wrapper);
var w = $(‘.outer:eq(0)‘, slidercontents).outerWidth() + parseFloat($(‘.outer:eq(0)‘, slidercontents).css(‘margin-left‘)) + parseFloat($(‘.outer:eq(0)‘, slidercontents).css(‘margin-right‘));
var width = (total + 1) * w;
var maxScroll = width - $(‘.image-slider-contents‘).outerWidth();
wrapper.css({
width: width
});
$(‘> div > div‘, slidercontents).css(‘display‘, ‘‘);
$(‘.outer‘, slidercontents).each(function(index) {
$(this).prepend($(‘‘).attr(‘src‘, ‘images/zoom.png‘).addClass(‘zoom‘)
.css({
cursor: ‘pointer‘,
‘position‘: ‘absolute‘,
‘float‘: ‘right‘,
right:-10,
top: -12,
width: 34,
height: 32
}));
/* 酷站代码整理 http://www.5icool.org */
$(‘.outer a‘).click(function(e) {
e.stopPropagation();
e.stopImmediatePropagation();
});
$(‘.outer‘).hover(function() {
$(this).addClass(‘active‘);
},
function() {
$(this).removeClass(‘active‘);
}).click(
function(e) {
e.stopPropagation();
e.stopImmediatePropagation();
var cls = $(this).attr(‘class‘).split(‘ ‘)[0];
var p = $(this).find(‘div‘);
var img = p.find(‘img‘).attr(‘src‘);
var preview = $(‘.preview‘);
var l = $(‘.image-slider‘).width() / 2 - preview.outerWidth() / 2;
var t = (p.offset().top - preview.height());
t -= t / 2;
preview.css({
left: l,
top: t
});
var text = p.find(‘a‘).html();
preview.find(‘img‘).attr(‘src‘, img).addClass(cls);
preview.find(‘.label‘).html(text);
preview.fadeIn("slow");
});
left -= w;
if (left + maxScroll >= 0) {
$(‘.contents-wrapper‘).stop(false, true).animate({
left: ‘-=‘ + w
},
settings.speed);
else
left += w;
backbutton.click(function() {
if (left left += w;
$(‘.contents-wrapper‘).stop(false, true).animate({
left: ‘+=‘ + w
},
settings.speed);
initialize();
return value + ‘px‘;
});
上一篇:左右切换css,html
下一篇:nodejs运行ts服务器