Skip to content

Commit

Permalink
Prepare release v1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nnattawat committed May 25, 2016
1 parent 4e33cbb commit bee93eb
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 17 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flip",
"version": "1.1.0",
"version": "1.1.1",
"dependencies": {
"jquery": "~2.0"
},
Expand Down
62 changes: 50 additions & 12 deletions dist/jquery.flip.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! flip - v1.1.0 - 2016-05-20
/*! flip - v1.1.1 - 2016-05-25
* https://github.com/nnattawat/flip
* Copyright (c) 2016 Nattawat Nonsung; Licensed MIT */
(function( $ ) {
Expand Down Expand Up @@ -28,7 +28,7 @@
*/
var Flip = function($el, options, callback) {
// Define default setting
var setting = $.extend({
this.setting = {
axis: "y",
reverse: false,
trigger: "click",
Expand All @@ -38,10 +38,48 @@
autoSize: true,
front: '.front',
back: '.back'
}, options );
};

this.setting = $.extend(this.setting, options);

if (typeof options.axis === 'string' && (options.axis.toLowerCase() === 'x' || options.axis.toLowerCase() === 'y')) {
this.setting.axis = options.axis.toLowerCase();
}

if (typeof options.reverse === "boolean") {
this.setting.reverse = options.reverse;
}

if (typeof options.trigger === 'string') {
this.setting.trigger = options.trigger.toLowerCase();
}

var speed = parseInt(options.speed);
if (!isNaN(speed)) {
this.setting.speed = speed;
}

if (typeof options.forceHeight === "boolean") {
this.setting.forceHeight = options.forceHeight;
}

if (typeof options.forceWidth === "boolean") {
this.setting.forceWidth = options.forceWidth;
}

if (typeof options.autoSize === "boolean") {
this.setting.autoSize = options.autoSize;
}

if (typeof options.front === 'string' || options.front instanceof $) {
this.setting.front = options.front;
}

if (typeof options.back === 'string' || options.back instanceof $) {
this.setting.back = options.back;
}

// Attributes
this.setting = $.extend(setting, options);
// Other attributes
this.element = $el;
this.frontElement = this.getFrontElement();
this.backElement = this.getBackElement();
Expand All @@ -60,7 +98,7 @@
// Providing a nicely wrapped up callback because transform is essentially async
self.element.one(whichTransitionEvent(), function() {
self.element.trigger('flip:done');
if (callback !== undefined) {
if (typeof callback === 'function') {
callback.call(self.element);
}
});
Expand Down Expand Up @@ -126,7 +164,7 @@
var self = this;

var faces = self.frontElement.add(self.backElement);
var rotateAxis = "rotate" + (self.setting.axis.toLowerCase() === "x" ? "x" : "y");
var rotateAxis = "rotate" + self.setting.axis;
var perspective = self.element["outer" + (rotateAxis === "rotatex" ? "Height" : "Width")]() * 2;
var elementCss = {
'perspective': perspective,
Expand Down Expand Up @@ -181,7 +219,7 @@
});

// This allows flip to be called for setup with only a callback (default settings)
if (callback !== undefined) {
if (typeof callback === 'function') {
callback.call(self.element);
}

Expand Down Expand Up @@ -222,17 +260,17 @@

attachEvents: function() {
var self = this;
if (self.setting.trigger.toLowerCase() === "click") {
if (self.setting.trigger === "click") {
self.element.on($.fn.tap ? "tap.flip" : "click.flip", $.proxy(self.clickHandler, self));
} else if (self.setting.trigger.toLowerCase() === "hover") {
} else if (self.setting.trigger === "hover") {
self.element.on('mouseenter.flip', $.proxy(self.hoverHandler, self));
self.element.on('mouseleave.flip', $.proxy(self.unflip, self));
}
},

flipChanged: function(callback) {
this.element.trigger('flip:change');
if (callback !== undefined) {
if (typeof callback === 'function') {
callback.call(this.element);
}
},
Expand Down Expand Up @@ -317,7 +355,7 @@
flip.changeSettings(options, callback);
}
} else { // Init
$(this).data('flip-model', new Flip($(this), options, callback));
$(this).data('flip-model', new Flip($(this), (options || {}), callback));
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.flip.min.js

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

Loading

0 comments on commit bee93eb

Please sign in to comment.