Skip to content

Commit

Permalink
optimising a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Visual Idiot committed Dec 4, 2015
1 parent 094dc42 commit 382e9c9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
14 changes: 13 additions & 1 deletion config.codekit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"CodeKitInfo": "This is a CodeKit 2.x project configuration file. It is designed to sync project settings across multiple machines. MODIFYING THE CONTENTS OF THIS FILE IS A POOR LIFE DECISION. If you do so, you will likely cause CodeKit to crash. This file is not useful unless accompanied by the project that created it in CodeKit 2. This file is not backwards-compatible with CodeKit 1.x. For more information, see: http:\/\/incident57.com\/codekit",
"creatorBuild": "19076",
"creatorBuild": "19099",
"files": {
"\/bower.json": {
"fileType": 524288,
Expand Down Expand Up @@ -277,10 +277,18 @@
"active": 0,
"flagValue": -1
},
"no_nested_string_interpolation": {
"active": 1,
"flagValue": -1
},
"no_plusplus": {
"active": 0,
"flagValue": -1
},
"no_private_function_fat_arrows": {
"active": 1,
"flagValue": -1
},
"no_stand_alone_at": {
"active": 1,
"flagValue": -1
Expand All @@ -289,6 +297,10 @@
"active": 1,
"flagValue": -1
},
"no_this": {
"active": 0,
"flagValue": -1
},
"no_throwing_strings": {
"active": 1,
"flagValue": -1
Expand Down
2 changes: 1 addition & 1 deletion dist/js/unslider-min.js

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

33 changes: 9 additions & 24 deletions src/js/unslider.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
// Either set true/false, or an object with the HTML
// elements for each arrow like below:
arrows: {
prev: '<a class="' + self._ + '-arrow prev"></a>',
next: '<a class="' + self._ + '-arrow next"></a>'
prev: '<a class="' + self._ + '-arrow prev">Prev</a>',
next: '<a class="' + self._ + '-arrow next">Next</a>'
},

// How should Unslider animate?
Expand Down Expand Up @@ -135,7 +135,7 @@
});

// Add swipe support
if(typeof jQuery.event.special.swipe !== undefined && self.options.swipe) {
if(jQuery.event.special.swipe && self.options.swipe) {
self.initSwipe();
}

Expand Down Expand Up @@ -380,10 +380,10 @@
self.current = Math.min(Math.max(0, to), self.total - 1);

if(self.options.nav) {
self.$nav.find('[data-slide="' + self.current + '"]')._toggleActive(self.options.activeClass);
self.$nav.find('[data-slide="' + self.current + '"]')._active(self.options.activeClass);
}

self.$slides.eq(self.current)._toggleActive(self.options.activeClass);
self.$slides.eq(self.current)._active(self.options.activeClass);

return self;
};
Expand Down Expand Up @@ -571,7 +571,7 @@
// They're both just helpful types of shorthand for
// anything that might take too long to write out or
// something that might be used more than once.
$.fn._toggleActive = function(className) {
$.fn._active = function(className) {
return this.addClass(className).siblings().removeClass(className);
};

Expand All @@ -587,15 +587,8 @@
};

$.fn._move = function() {
var type = 'animate';

this.stop(true, true);

if($.fn.velocity) {
type = 'velocity';
}

return $.fn[type].apply(this, arguments);
return $.fn[$.fn.velocity ? 'velocity' : 'animate'].apply(this, arguments);
};

// And set up our jQuery plugin
Expand All @@ -609,18 +602,10 @@
if(typeof opts === 'string' && $this.data('unslider')) {
opts = opts.split(':');

var fn = opts[0];
var call = $this.data('unslider')[fn];
var call = $this.data('unslider')[opts[0]];

// Do we have arguments to pass to the string-function?
if(opts[1]) {
var args = opts[1].split(',');
return $.isFunction(call) && call.apply($this, args);
}

$.isFunction(call) && call();

return this;
$.isFunction(call) && call.apply($this, args ? null : opts[1].split(','));
}

return $this.data('unslider', new $.Unslider($this, opts));
Expand Down

0 comments on commit 382e9c9

Please sign in to comment.