Skip to content

Commit

Permalink
commit suning js-file
Browse files Browse the repository at this point in the history
  • Loading branch information
G-c-chen committed Oct 17, 2018
1 parent 91c08fe commit f90823b
Show file tree
Hide file tree
Showing 14 changed files with 24,001 additions and 0 deletions.
62 changes: 62 additions & 0 deletions suning/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
$(function() {
/* 手势切换轮播图*/
/*1.自动轮播 无缝*/
/*2.点随着变化*/
/*3.完成手势切换*/
var $banner = $('.sn_banner');
var width = $banner.width();
// console.log(width);
var $imageBox = $banner.find('ul:first');
var $pointBox = $banner.find('ul:last');
var $points = $pointBox.find('li');

var animationFuc = function() {
$imageBox.animate({ transform: 'translateX(' + (-index * width) + 'px)' }, 200, function() {
// 动画执行完成的回调

if (index >= 9) {
index = 1;
// 瞬间完成
$imageBox.css({ transform: 'translateX(' + (-index * width) + 'px)' });
} else if (index <= 0) {
index = 8;
// 瞬间完成
$imageBox.css({ transform: 'translateX(' + (-index * width) + 'px)' });
}
/*2.点随着变化*/
$points.removeClass('now').eq(index - 1).addClass('now');
});
}

/*1.自动轮播 无缝*/
var index = 1;
var timer = setInterval(function() {
index++;
// 动画
animationFuc();
}, 3000);
/*3.完成手势切换*/
/*左滑的手势 下一张*/
$banner.on('swipeLeft', function() {
clearInterval(timer);
index++;
animationFuc();
timer = setInterval(function() {
index++;
// 动画
animationFuc();
}, 3000);
});
/*右滑的手势 上一张*/
$banner.on('swipeRight', function() {
clearInterval(timer);
index--;
animationFuc();
timer = setInterval(function() {
index++;
// 动画
animationFuc();
}, 3000);
});

});
1 change: 1 addition & 0 deletions suning/less/index-swiper.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions suning/less/index-swiper.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*变量*/
@import "var";
/*混入*/
@import "mixins";
/*适配*/
@import "adapter";
/*重置样式*/
@import "reset";

//模块
@import "topBar";
@import "nav";
@import "tabs";
Loading

0 comments on commit f90823b

Please sign in to comment.