Skip to content

Commit

Permalink
adding responsive image support
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisantonellis committed Feb 2, 2016
1 parent 7094cac commit ba0d480
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 62 deletions.
23 changes: 14 additions & 9 deletions build/css/freezeframe_styles.css

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

2 changes: 1 addition & 1 deletion build/css/freezeframe_styles.min.css

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

27 changes: 17 additions & 10 deletions build/js/freezeframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,18 @@ var freezeframe = (function($) {
// dont run if no images found
freezeframe.prototype.setup = function() {
var ff = this,
setup_required = this.images.not('.freezeframe-setup');
setup_required = this.images.not('.freezeframe-setup'),
container_classnames = ['freezeframe-container'];

setup_required.each(function(e) {
var $image = $(this);

$image.addClass('freezeframe-setup freezeframe-image');

if($image.hasClass('freezeframe-responsive')) {
container_classnames.push('freezeframe-responsive');
}

$canvas = $('<canvas />', {
class: 'freezeframe-canvas'
}).attr({
Expand All @@ -107,7 +112,7 @@ var freezeframe = (function($) {

$image.add($canvas).wrapAll(
$('<div />', {
class: 'freezeframe-container'
class: container_classnames.join(' ')
})
);

Expand Down Expand Up @@ -136,13 +141,15 @@ var freezeframe = (function($) {
$canvas.attr({
'width': image_width,
'height': image_height
}).css({
'margin-right': '-' + image_width + 'px'
})
});
// }).css({
// 'margin-right': '-' + image_width + 'px'
// })

context = $canvas[0].getContext('2d');
context.mozImageSmoothingEnabled = false;
context.imageSmoothingEnabled = false;
context.mozImageSmoothingEnabled = true;
context.webkitImageSmoothingEnabled = true;
context.imageSmoothingEnabled = true;
context.drawImage($_image[0], 0, 0, image_width, image_height);

$canvas.addClass('freezeframe-canvas-ready').on(transitionEnd, function() {
Expand Down Expand Up @@ -192,14 +199,14 @@ var freezeframe = (function($) {
// hover
if((!ff.is_touch_device && ff.options.non_touch_device_trigger_event == 'hover') || (ff.is_touch_device)) {

$canvas.mouseenter(function() {
$image.mouseenter(function() {
(function() {
$image.attr('src', $image[0].src);
$canvas.removeClass('freezeframe-canvas-ready').addClass('freezeframe-canvas-active');
})();
})

$canvas.mouseleave(function() {
$image.mouseleave(function() {
(function() {
$canvas.removeClass('freezeframe-canvas-active').addClass('freezeframe-canvas-ready');
})();
Expand All @@ -209,7 +216,7 @@ var freezeframe = (function($) {
// click
if((!ff.is_touch_device && ff.options.non_touch_device_trigger_event == 'click') || (ff.is_touch_device)) {

$canvas.click(function() {
$image.click(function() {

(function() {

Expand Down
Loading

0 comments on commit ba0d480

Please sign in to comment.