Skip to content

Commit bee93eb

Browse files
committed
Prepare release v1.1.1
1 parent 4e33cbb commit bee93eb

File tree

5 files changed

+55
-17
lines changed

5 files changed

+55
-17
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flip",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"dependencies": {
55
"jquery": "~2.0"
66
},

dist/jquery.flip.js

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! flip - v1.1.0 - 2016-05-20
1+
/*! flip - v1.1.1 - 2016-05-25
22
* https://github.com/nnattawat/flip
33
* Copyright (c) 2016 Nattawat Nonsung; Licensed MIT */
44
(function( $ ) {
@@ -28,7 +28,7 @@
2828
*/
2929
var Flip = function($el, options, callback) {
3030
// Define default setting
31-
var setting = $.extend({
31+
this.setting = {
3232
axis: "y",
3333
reverse: false,
3434
trigger: "click",
@@ -38,10 +38,48 @@
3838
autoSize: true,
3939
front: '.front',
4040
back: '.back'
41-
}, options );
41+
};
42+
43+
this.setting = $.extend(this.setting, options);
44+
45+
if (typeof options.axis === 'string' && (options.axis.toLowerCase() === 'x' || options.axis.toLowerCase() === 'y')) {
46+
this.setting.axis = options.axis.toLowerCase();
47+
}
48+
49+
if (typeof options.reverse === "boolean") {
50+
this.setting.reverse = options.reverse;
51+
}
52+
53+
if (typeof options.trigger === 'string') {
54+
this.setting.trigger = options.trigger.toLowerCase();
55+
}
56+
57+
var speed = parseInt(options.speed);
58+
if (!isNaN(speed)) {
59+
this.setting.speed = speed;
60+
}
61+
62+
if (typeof options.forceHeight === "boolean") {
63+
this.setting.forceHeight = options.forceHeight;
64+
}
65+
66+
if (typeof options.forceWidth === "boolean") {
67+
this.setting.forceWidth = options.forceWidth;
68+
}
69+
70+
if (typeof options.autoSize === "boolean") {
71+
this.setting.autoSize = options.autoSize;
72+
}
73+
74+
if (typeof options.front === 'string' || options.front instanceof $) {
75+
this.setting.front = options.front;
76+
}
77+
78+
if (typeof options.back === 'string' || options.back instanceof $) {
79+
this.setting.back = options.back;
80+
}
4281

43-
// Attributes
44-
this.setting = $.extend(setting, options);
82+
// Other attributes
4583
this.element = $el;
4684
this.frontElement = this.getFrontElement();
4785
this.backElement = this.getBackElement();
@@ -60,7 +98,7 @@
6098
// Providing a nicely wrapped up callback because transform is essentially async
6199
self.element.one(whichTransitionEvent(), function() {
62100
self.element.trigger('flip:done');
63-
if (callback !== undefined) {
101+
if (typeof callback === 'function') {
64102
callback.call(self.element);
65103
}
66104
});
@@ -126,7 +164,7 @@
126164
var self = this;
127165

128166
var faces = self.frontElement.add(self.backElement);
129-
var rotateAxis = "rotate" + (self.setting.axis.toLowerCase() === "x" ? "x" : "y");
167+
var rotateAxis = "rotate" + self.setting.axis;
130168
var perspective = self.element["outer" + (rotateAxis === "rotatex" ? "Height" : "Width")]() * 2;
131169
var elementCss = {
132170
'perspective': perspective,
@@ -181,7 +219,7 @@
181219
});
182220

183221
// This allows flip to be called for setup with only a callback (default settings)
184-
if (callback !== undefined) {
222+
if (typeof callback === 'function') {
185223
callback.call(self.element);
186224
}
187225

@@ -222,17 +260,17 @@
222260

223261
attachEvents: function() {
224262
var self = this;
225-
if (self.setting.trigger.toLowerCase() === "click") {
263+
if (self.setting.trigger === "click") {
226264
self.element.on($.fn.tap ? "tap.flip" : "click.flip", $.proxy(self.clickHandler, self));
227-
} else if (self.setting.trigger.toLowerCase() === "hover") {
265+
} else if (self.setting.trigger === "hover") {
228266
self.element.on('mouseenter.flip', $.proxy(self.hoverHandler, self));
229267
self.element.on('mouseleave.flip', $.proxy(self.unflip, self));
230268
}
231269
},
232270

233271
flipChanged: function(callback) {
234272
this.element.trigger('flip:change');
235-
if (callback !== undefined) {
273+
if (typeof callback === 'function') {
236274
callback.call(this.element);
237275
}
238276
},
@@ -317,7 +355,7 @@
317355
flip.changeSettings(options, callback);
318356
}
319357
} else { // Init
320-
$(this).data('flip-model', new Flip($(this), options, callback));
358+
$(this).data('flip-model', new Flip($(this), (options || {}), callback));
321359
}
322360
});
323361
}

dist/jquery.flip.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)