Skip to content

Commit

Permalink
update version
Browse files Browse the repository at this point in the history
  • Loading branch information
ganlanyuan committed Nov 3, 2016
1 parent fe62bc5 commit 17d03f2
Show file tree
Hide file tree
Showing 11 changed files with 253 additions and 120 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tiny-slider
![version](https://img.shields.io/badge/Version-0.6.2-green.svg)
![version](https://img.shields.io/badge/Version-1.0.0-green.svg)
Tiny slider for all purposes, inspired by [Owl Carousel](http://owlcarousel.owlgraphic.com/).
Works on morden browsers and IE8+.
[demo](http://creatiointl.org/william/tiny-slider/v1/demo/)
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tiny-slider",
"version": "0.6.2",
"version": "1.0.0",
"homepage": "https://github.com/ganlanyuan/tiny-slider",
"authors": [
"WilliamLin <ganlanyuan@gmail.com>"
Expand Down
2 changes: 1 addition & 1 deletion dist/min/tiny-slider.ie8.js

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

2 changes: 1 addition & 1 deletion dist/min/tiny-slider.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/min/tiny-slider.native.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions dist/tiny-slider.ie8.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ if (!Object.keys) {
return keys;
};
}
// Array.isArray
if (!Array.isArray) {
Array.isArray = function(obj) {
return Object.prototype.toString.call(obj) == "[object Array]";
};
}
// addEventListener
// removeEventListener
// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener?redirectlocale=en-US&redirectslug=DOM%2FEventTarget.addEventListener#Compatibility
Expand Down
118 changes: 80 additions & 38 deletions dist/tiny-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ gn.unwrap = function (els) {
};
/**
* tiny-slider
* @version 0.6.2
* @version 1.0.0
* @author William Lin
* @license The MIT License (MIT)
* @github https://github.com/ganlanyuan/tiny-slider/
Expand All @@ -579,7 +579,6 @@ gn.unwrap = function (els) {
var tns = (function () {
'use strict';

// get supported property, KEYs
var TRANSFORM = gn.getSupportedProp([
'transform',
'WebkitTransform',
Expand Down Expand Up @@ -889,7 +888,7 @@ var tns = (function () {
function msInit() {
if (navigator.msMaxTouchPoints) {
wrapper.classList.add('ms-touch');
wrapper.addEventListener('scroll', ie10Scroll, false);
addEvents(wrapper, ['scroll', ie10Scroll]);
}
}

Expand Down Expand Up @@ -1029,46 +1028,56 @@ var tns = (function () {
function addSliderEvents() {
if (mode === 'carousel') {
if (TRANSITIONEND) {
container.addEventListener(TRANSITIONEND, onTransitionEnd, false);
addEvents(container, [TRANSITIONEND, onTransitionEnd]);
}
if (touch) {
container.addEventListener('touchstart', onTouchStart, false);
container.addEventListener('touchmove', onTouchMove, false);
container.addEventListener('touchend', onTouchEnd, false);
container.addEventListener('touchcancel', onTouchEnd, false);
addEvents(container, [
['touchstart', onTouchStart],
['touchmove', onTouchMove],
['touchend', onTouchEnd],
['touchcancel', onTouchEnd]
]);
}
}
if (nav) {
for (var y = 0; y < slideCount; y++) {
navItems[y].addEventListener('click', onClickNav, false);
navItems[y].addEventListener('keydown', onKeydownNav, false);
addEvents(navItems[y],[
['click', onClickNav],
['keydown', onKeydownNav]
]);
}
}
if (controls) {
prevButton.addEventListener('click', onClickPrev, false);
nextButton.addEventListener('click', onClickNext, false);
prevButton.addEventListener('keydown', onKeydownControl, false);
nextButton.addEventListener('keydown', onKeydownControl, false);
addEvents(prevButton,[
['click', onClickPrev],
['keydown', onKeydownControl]
]);
addEvents(nextButton,[
['click', onClickNext],
['keydown', onKeydownControl]
]);
}
if (autoplay) {
autoplayButton.addEventListener('click', toggleAnimation, false);
addEvents(autoplayButton, ['click', toggleAnimation]);

if (controls) {
prevButton.addEventListener('click', stopAnimation, false );
nextButton.addEventListener('click', stopAnimation, false );
addEvents(prevButton, ['click', stopAnimation]);
addEvents(nextButton, ['click', stopAnimation]);
}

if (nav) {
for (var b = 0; b < slideCount; b++) {
navItems[b].addEventListener('click', stopAnimation, false);
for (var b = slideCount; b--;) {
addEvents(navItems[b], ['click', stopAnimation]);
}
}
}
if (arrowKeys) {
document.addEventListener('keydown', onKeydownDocument, false);
addEvents(document, ['keydown', onKeydownDocument]);
}
window.addEventListener('resize', onResize, false);
window.addEventListener('scroll', onScroll, false);
addEvents(window, [
['resize', onResize],
['scroll', onScroll]
]);
}

// lazyload
Expand Down Expand Up @@ -1179,7 +1188,6 @@ var tns = (function () {
}
}

// === VERTICAL CAROUSEL FUNCTIONS === //
// get the distance from the top edge of the first slide to each slide
// (init) => slideTopEdges
function getSlideTopEdges() {
Expand Down Expand Up @@ -1354,8 +1362,8 @@ var tns = (function () {
} else {
return function () {
slideItemsOut = [];
slideItems[indexCached].removeEventListener(TRANSITIONEND, onTransitionEnd, false);
slideItems[index].addEventListener(TRANSITIONEND, onTransitionEnd, false);
removeEvents(slideItems[indexCached], [TRANSITIONEND, onTransitionEnd]);
addEvents(slideItems[index], [TRANSITIONEND, onTransitionEnd]);
// slideItems[indexCached].removeEventListener(ANIMATIONEND, onTransitionEnd, false);
// slideItems[index].addEventListener(ANIMATIONEND, onTransitionEnd, false);

Expand Down Expand Up @@ -1880,25 +1888,27 @@ var tns = (function () {

// remove arrowKeys eventlistener
if (arrowKeys) {
document.removeEventListener('keydown', onKeydownDocument, false);
removeEvents(document, ['keydown', onKeydownDocument]);
}

// remove window event listeners
window.removeEventListener('resize', onResize, false);
window.removeEventListener('scroll', onScroll, false);
removeEvents(window, [
['resize', onResize],
['scroll', onScroll]
]);
},

// $ Private methods, for test only
hasAttr: hasAttr,
getAttr: getAttr,
setAttrs: setAttrs,
removeAttrs: removeAttrs,
removeEvents: removeEvents,
getSlideId: getSlideId,
toDegree: toDegree,
getTouchDirection: getTouchDirection,
hideElement: hideElement,
showElement: showElement,
// hasAttr: hasAttr,
// getAttr: getAttr,
// setAttrs: setAttrs,
// removeAttrs: removeAttrs,
// removeEvents: removeEvents,
// getSlideId: getSlideId,
// toDegree: toDegree,
// getTouchDirection: getTouchDirection,
// hideElement: hideElement,
// showElement: showElement,
};
}

Expand Down Expand Up @@ -1995,6 +2005,38 @@ var tns = (function () {
return false; // explicit for ie9-
}

function addEvents(el, events) {
function add(arr) {
el.addEventListener(arr[0], arr[1], false);
}

if (Array.isArray(events)) {
if (Array.isArray(events[0])) {
for (var i = events.length; i--;) {
add(events[i]);
}
} else {
add(events);
}
}
}

function removeEvents(el, events) {
function remove(arr) {
el.removeEventListener(arr[0], arr[1], false);
}

if (Array.isArray(events)) {
if (Array.isArray(events[0])) {
for (var i = events.length; i--;) {
remove(events[i]);
}
} else {
remove(events);
}
}
}

var events = {
events: {},
on: function (eventName, fn) {
Expand Down
Loading

0 comments on commit 17d03f2

Please sign in to comment.