Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Flip horizontal #93

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions jquery.iviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ $.widget( "ui.iviewer", $.ui.mouse, {
this.zoom_object = {}; //object to show zoom status

this._angle = 0;
this._flipH = -1;

this.current_zoom = this.options.zoom;

Expand Down Expand Up @@ -756,6 +757,13 @@ $.widget( "ui.iviewer", $.ui.mouse, {
this._trigger('angle', 0, { angle: this.img_object.angle() });
},

/**
* Flip horizontal
*/
flip_h: function() {
this.img_object.flip_h();
},

/**
* finds closest multiplier rate for value
* basing on zoom_base and zoom_delta values from settings
Expand Down Expand Up @@ -1004,6 +1012,13 @@ $.ui.iviewer.ImageObject = function(do_anim) {
this.orig_height(h);
this.display_width(w);
this.display_height(h);

var userAgent = window.navigator.userAgent.toLowerCase();
if (userAgent.indexOf('msie') != -1) {
this._flipH = 1;
} else {
this._flipH = -1;
}
};

/**
Expand Down Expand Up @@ -1153,9 +1168,27 @@ $.ui.iviewer.ImageObject = function(do_anim) {
marginTop: ieTransforms[deg].marginTop * this.display_diff() / 2
});
}

// reset flip
this._flipH = -1;
},
function() { return this._angle; });

this.flip_h = function() {
var img = this._img;
var curAngle = this._angle;
var cssVal = 'scaleX(' + this._flipH + ')';

jQuery.each(['', 'Webkit', 'Moz', 'O', 'ms'], function(i, prefix) {
img.css(prefix + 'Transform', cssVal + ' rotate(' + curAngle + 'deg)');
});

img.css('filter', 'FlipH');
img.css('msFilter', 'FlipH');

this._flipH = -this._flipH;
};

/**
* Map point in the container coordinates to the point in image coordinates.
* You will get coordinates of point on image with respect to rotation,
Expand Down
Loading